forked from fanruan/design
Browse Source
Merge in DESIGN/design from ~QINGHUI.LIU/design:release/10.0 to release/10.0 * commit 'e04882b2afd82eebc7aea1b82f6ffdad3d4e777e': 增加子类来代替参数 更换空字符、跟新行尺寸 CHART-14182 修改渐变风格面板和条件属性面板feature/big-screen
Qinghui.Liu
4 years ago
7 changed files with 329 additions and 69 deletions
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue