Browse Source

Merge pull request #4330 in DESIGN/design from feature/10.0 to feature/x

* commit 'ebd8b8c6ebcf91bd1abfbca0daec3bca25af3da8':
  CHART-19306 仪表盘配色面板修改
persist/11.0
superman 4 years ago
parent
commit
e6667c1b51
  1. 121
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneWithMaxMin.java
  2. 35
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java
  3. 6
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartBeautyPane.java
  4. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartAbstractPlotSeriesPane.java
  5. 104
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartColorValueSeriesPane.java
  6. 92
      designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartMultiColorSeriesPane.java
  7. 113
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeBeautyPane.java
  8. 230
      designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

121
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/ColorPickerPaneWithMaxMin.java

@ -0,0 +1,121 @@
package com.fr.design.mainframe.chart.gui.style.series;
import com.fr.base.BaseFormula;
import com.fr.chart.chartglyph.MapHotAreaColor;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.Color;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-05-18
*/
public class ColorPickerPaneWithMaxMin extends ColorPickerPaneWithFormula {
private double MAX = Double.MAX_VALUE / 2;
private double MIN = -(Double.MAX_VALUE / 2);
private BaseFormula[] valueArray;
private JPanel autoPane;
public ColorPickerPaneWithMaxMin(AbstractAttrNoScrollPane container, String meterString) {
this(container, meterString, null);
}
public ColorPickerPaneWithMaxMin(AbstractAttrNoScrollPane container, String meterString, JPanel autoPane) {
super(container, meterString);
if (autoPane == null) {
return;
}
this.autoPane = autoPane;
this.getDesignTypeButtonGroup().addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
checkAutoPane();
}
});
}
private void checkAutoPane() {
if (getDesignTypeButtonGroup().getSelectedIndex() == 0) {
autoPane.setVisible(true);
} else {
autoPane.setVisible(false);
}
}
public void refreshGroupPane(Color[] colorArray, BaseFormula[] valueArray) {
this.valueArray = valueArray;
super.refreshGroupPane(colorArray, valueArray);
}
protected void setTextValue4Index(int index, String value) {
TinyFormulaPane tinyFormulaPane = (TinyFormulaPane) textFieldList.get(index);
setTextState(tinyFormulaPane, index, textFieldList.size() - 1, value);
}
protected JComponent getNewTextFieldComponent(int i, String value) {
TinyFormulaPane textField = new TinyFormulaPaneWithEnable();
textField.setBounds(0, i * 2 * TEXTFIELD_HEIGHT, TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT);
setTextState(textField, i, valueArray.length - 1, value);
return textField;
}
protected String getValue4Index(int i) {
if (i == 0) {
return String.valueOf(MAX);
}
if (i == textFieldList.size() - 1) {
return String.valueOf(MIN);
}
return ((TinyFormulaPane) textFieldList.get(i)).getUITextField().getText();
}
protected BaseFormula[] getValueArray(int count) {
BaseFormula[] valueArray = new BaseFormula[count + 1];
valueArray[0] = BaseFormula.createFormulaBuilder().build(MAX);
valueArray[count] = BaseFormula.createFormulaBuilder().build(MIN);
for (int i = 1; i < count; i++) {
if (i >= textFieldList.size() - 1) {
valueArray[i] = BaseFormula.createFormulaBuilder().build((count - i) * VALUE);
} else {
valueArray[i] = BaseFormula.createFormulaBuilder().build(getValue4Index(i));
}
}
return valueArray;
}
private void setTextState(TinyFormulaPane tinyFormulaPane, int index, int maxIndex, String value) {
boolean enable = false;
if (index == 0) {
value = "∞";
} else if (index == maxIndex) {
value = "-∞";
} else {
enable = true;
}
tinyFormulaPane.getUITextField().setText(value);
tinyFormulaPane.setEnabled(enable);
}
public void populateBean(MapHotAreaColor hotAreaColor) {
super.populateBean(hotAreaColor);
if (autoPane != null) {
checkAutoPane();
}
}
public class TinyFormulaPaneWithEnable extends TinyFormulaPane {
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
formulaTextField.setEnabled(enabled);
formulaTextFieldButton.setEnabled(enabled);
}
}
}

35
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java

@ -13,6 +13,7 @@ import com.fr.design.gui.frpane.UINumberDragPane;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.gui.ipoppane.PopupHider;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.color.ColorControlWindow;
@ -53,7 +54,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
protected static final int TEXTFIELD_WIDTH = 130;
protected static final int UPCONTROLPANE_WIDTH = 230;
private static final int LAYOUR_DET = 6;
private static final double VALUE = 100;
public static final double VALUE = 100;
protected ArrayList<JComponent> textFieldList;
private List<ColorRecButton> colorRecList = new ArrayList<ColorRecButton>();
@ -171,7 +172,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
regionNumPane.updateBean().intValue()), getValueArray(regionNumPane.updateBean().intValue()));
}
});
designTypeButtonGroup = new UIButtonGroup<Integer>(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")}, new Integer[]{0, 1});
designTypeButtonGroup = new UIButtonGroup<>(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")}, new Integer[]{0, 1});
designTypeButtonGroup.setSelectedIndex(0);
designTypeButtonGroup.addChangeListener(new ChangeListener() {
@Override
@ -201,11 +202,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
};
double p = TableLayout.PREFERRED;
double e = getEditAreaWidth ();
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
double e = getEditAreaWidth();
double d = getDescriptionWidth();
double[] columnSize = {d, e};
double[] rowSize = {p};
Component[][] tmpComp = new Component[][]{new Component[]{new BoldFontTextLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), regionNumPane}};
Component[][] tmpComp = new Component[][]{new Component[]{new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), regionNumPane}};
stagePanel = TableLayout4VanChartHelper.createGapTableLayoutPane(tmpComp, rowSize, columnSize);
@ -226,10 +227,14 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
refreshGroupPane(colors, getValueArray(number));
}
protected double getEditAreaWidth () {
protected double getEditAreaWidth() {
return TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
}
protected double getDescriptionWidth() {
return TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH;
}
protected ArrayList getTextFieldList(){
return new ArrayList<ColorPickerPaneNumFiled>();
}
@ -272,11 +277,11 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
*/
public Dimension getPreferredSize() {
if (designTypeButtonGroup.getSelectedIndex() == 0) {
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + MARGIN_TOP);
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width, upControlPane.getPreferredSize().height + getBoundY());
} else {
int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + MARGIN_TOP;
int extra = stagePanel == null ? 0 : stagePanel.getPreferredSize().height + getBoundY();
return new Dimension(colorGroup.getPreferredSize().width + textGroup.getPreferredSize().width,
extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + MARGIN_TOP);
extra + textGroup.getPreferredSize().height + upControlPane.getPreferredSize().height + OFF_HEIGHT + getBoundY());
}
}
@ -604,10 +609,10 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
@Override
public void layoutContainer(Container parent) {
upControlPane.setBounds(MARGIN_LEFT, MARGIN_TOP, UPCONTROLPANE_WIDTH, upControlPane.getPreferredSize().height + MARGIN_TOP);
stagePanel.setBounds(MARGIN_LEFT, upControlPane.getPreferredSize().height + LAYOUR_DET + MARGIN_TOP, UPCONTROLPANE_WIDTH, stagePanel.getPreferredSize().height);
colorGroup.setBounds( getColorgroupMarginLeft (), 2 * MARGIN_TOP + upControlPane.getPreferredSize().height + stagePanel.getPreferredSize().height + 2 * LAYOUR_DET, colorGroup.getPreferredSize().width, colorGroup.getPreferredSize().height + upControlPane.getPreferredSize().height);
textGroup.setBounds(colorGroup.getPreferredSize().width + getColorgroupMarginLeft (), upControlPane.getPreferredSize().height + stagePanel.getPreferredSize().height + 2 * LAYOUR_DET + MARGIN_TOP, textGroup.getPreferredSize().width, textGroup.getPreferredSize().height);
upControlPane.setBounds(getBoundX(), getBoundY(), UPCONTROLPANE_WIDTH, upControlPane.getPreferredSize().height + MARGIN_TOP);
stagePanel.setBounds(getBoundX(), upControlPane.getPreferredSize().height + LAYOUR_DET + getBoundY(), UPCONTROLPANE_WIDTH, stagePanel.getPreferredSize().height);
colorGroup.setBounds( getColorgroupMarginLeft (), 2 * getBoundY() + upControlPane.getPreferredSize().height + stagePanel.getPreferredSize().height + 2 * LAYOUR_DET, colorGroup.getPreferredSize().width, colorGroup.getPreferredSize().height + upControlPane.getPreferredSize().height);
textGroup.setBounds(colorGroup.getPreferredSize().width + getColorgroupMarginLeft (), upControlPane.getPreferredSize().height + stagePanel.getPreferredSize().height + 2 * LAYOUR_DET + getBoundY(), textGroup.getPreferredSize().width, textGroup.getPreferredSize().height);
}
@Override
@ -693,7 +698,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
refreshPane();
}
private void initContainerLister(){
protected void initContainerLister(){
this.container.initAllListeners();
}
@ -761,7 +766,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver {
return ChartBaseUtils.createColorsWithHSB(color, sum);
}
private BaseFormula[] getValueArray(int count) {
protected BaseFormula[] getValueArray(int count) {
BaseFormula[] valueArray = new BaseFormula[count + 1];
for (int i = 0; i < valueArray.length; i++) {
if (i >= textFieldList.size()) {

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

@ -44,7 +44,7 @@ public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
double[] rowSize = {p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Gradient_Style")), gradientTypeBox},
new Component[]{new UILabel(labelName()), gradientTypeBox},
};
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize);
@ -57,6 +57,10 @@ public class VanChartBeautyPane extends BasicBeanPane<GradientStyle> {
};
}
protected String labelName() {
return Toolkit.i18nText("Fine-Design_Chart_Gradient_Style");
}
public void populateBean(GradientStyle gradientStyle) {
gradientTypeBox.setSelectedIndex(this.convertGradientTypeToIndex(gradientStyle.getGradientType()));
}

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

@ -147,7 +147,7 @@ public abstract class VanChartAbstractPlotSeriesPane extends AbstractPlotSeriesP
}
}
private void checkFillStylePane(GradientStyle gradientStyle) {
protected void checkFillStylePane(GradientStyle gradientStyle) {
if (vanChartFillStylePane != null) {
vanChartFillStylePane.setVisible(gradientStyle.getGradientType() != GradientType.CUSTOM);
}

104
designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartColorValueSeriesPane.java

@ -2,42 +2,27 @@ package com.fr.van.chart.designer.style.series;
import com.fr.chart.chartattr.Plot;
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.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.plugin.chart.range.VanChartRangeLegend;
import com.fr.plugin.chart.type.LegendType;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.component.VanChartBeautyPane;
import com.fr.van.chart.designer.component.VanChartValueColorPane;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-08-03
*/
public abstract class VanChartColorValueSeriesPane extends VanChartAbstractPlotSeriesPane {
//颜色划分切换
private UIButtonGroup<String> colorDivideButton;
public abstract class VanChartColorValueSeriesPane extends VanChartMultiColorSeriesPane {
private VanChartValueColorPane vanChartValueColorPane;
private JPanel colorDividePane;
public VanChartColorValueSeriesPane(ChartStylePane parent, Plot plot) {
super(parent, plot);
}
@ -51,79 +36,36 @@ public abstract class VanChartColorValueSeriesPane extends VanChartAbstractPlotS
this.vanChartValueColorPane = vanChartValueColorPane;
}
//获取颜色面板
protected JPanel getColorPane() {
JPanel panel = new JPanel(new BorderLayout());
JPanel colorChoosePane = createColorChoosePane();
if (colorChoosePane != null) {
panel.add(colorChoosePane, BorderLayout.CENTER);
}
stylePane = createStylePane();
setColorPaneContent(panel);
JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel);
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
return panel.getComponentCount() == 0 ? null : colorPane;
}
protected JPanel createColorChoosePane() {
vanChartFillStylePane = getVanChartFillStylePane();
if (vanChartFillStylePane != null) {
JPanel divideButtonPane = initDivideButtonPane();
vanChartValueColorPane = new VanChartValueColorPane((VanChartStylePane) parentPane);
colorDividePane = new JPanel(new CardLayout()) {
@Override
public Dimension getPreferredSize() {
if (colorDivideButton.getSelectedIndex() == 0) {
return vanChartFillStylePane.getPreferredSize();
} else {
return vanChartValueColorPane.getPreferredSize();
}
}
};
colorDividePane.add(vanChartFillStylePane, "series");
colorDividePane.add(vanChartValueColorPane, "value");
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] col = {f};
double[] row = {p, p, p};
Component[][] components = new Component[][]{
new Component[]{divideButtonPane},
new Component[]{colorDividePane}
};
return TableLayoutHelper.createCommonTableLayoutPane(components, row, col, 0);
return super.createColorChoosePane();
}
return null;
}
private JPanel initDivideButtonPane() {
colorDivideButton = new UIButtonGroup<>(new String[]{
protected UIButtonGroup<String> createDivideButton() {
return new UIButtonGroup<>(new String[]{
Toolkit.i18nText("Fine-Design_Chart_Series"),
Toolkit.i18nText("Fine-Design_Chart_Use_Value")
}, new String[]{"series", "value"});
colorDivideButton.addActionListener(new ActionListener() {
}
protected JPanel createColorDividePane() {
vanChartValueColorPane = new VanChartValueColorPane((VanChartStylePane) parentPane);
JPanel colorDividePane = new JPanel(new CardLayout()) {
@Override
public void actionPerformed(ActionEvent e) {
checkCardPane();
public Dimension getPreferredSize() {
if (getColorDivideButton().getSelectedIndex() == 0) {
return vanChartFillStylePane.getPreferredSize();
} else {
return vanChartValueColorPane.getPreferredSize();
}
}
});
colorDivideButton.setSelectedIndex(0);
UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color_Divide"));
Component[][] labelComponent = new Component[][]{
new Component[]{label, colorDivideButton},
};
JPanel gapTableLayoutPane = TableLayout4VanChartHelper.createGapTableLayoutPane(labelComponent);
gapTableLayoutPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
return gapTableLayoutPane;
}
private void checkCardPane() {
CardLayout cardLayout = (CardLayout) colorDividePane.getLayout();
cardLayout.show(colorDividePane, colorDivideButton.getSelectedItem());
colorDividePane.validate();
colorDividePane.repaint();
colorDividePane.add(vanChartFillStylePane, "series");
colorDividePane.add(vanChartValueColorPane, "value");
return colorDividePane;
}
//风格
@ -139,9 +81,9 @@ public abstract class VanChartColorValueSeriesPane extends VanChartAbstractPlotS
return;
}
super.updateBean(plot);
if (colorDivideButton != null) {
if (getColorDivideButton() != null) {
VanChartRangeLegend legend = (VanChartRangeLegend) plot.getLegend();
int selectedIndex = colorDivideButton.getSelectedIndex();
int selectedIndex = getColorDivideButton().getSelectedIndex();
if (selectedIndex == 0) {
legend.setLegendType(LegendType.ORDINARY);
} else {
@ -158,13 +100,13 @@ public abstract class VanChartColorValueSeriesPane extends VanChartAbstractPlotS
return;
}
super.populateBean(plot);
if (colorDivideButton != null) {
if (getColorDivideButton() != null) {
VanChartRangeLegend legend = (VanChartRangeLegend) plot.getLegend();
LegendType legendType = legend.getLegendType();
if (legendType == LegendType.ORDINARY) {
colorDivideButton.setSelectedIndex(0);
getColorDivideButton().setSelectedIndex(0);
} else {
colorDivideButton.setSelectedIndex(1);
getColorDivideButton().setSelectedIndex(1);
}
vanChartValueColorPane.populateBean(legend);
checkCardPane();

92
designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartMultiColorSeriesPane.java

@ -0,0 +1,92 @@
package com.fr.van.chart.designer.style.series;
import com.fr.chart.chartattr.Plot;
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.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-05-19
*/
public abstract class VanChartMultiColorSeriesPane extends VanChartAbstractPlotSeriesPane {
//颜色划分切换
private UIButtonGroup<String> colorDivideButton;
private JPanel colorDividePane;
public VanChartMultiColorSeriesPane(ChartStylePane parent, Plot plot) {
super(parent, plot);
}
public UIButtonGroup<String> getColorDivideButton() {
return colorDivideButton;
}
//获取颜色面板
protected JPanel getColorPane() {
JPanel panel = new JPanel(new BorderLayout());
JPanel colorChoosePane = createColorChoosePane();
if (colorChoosePane != null) {
panel.add(colorChoosePane, BorderLayout.CENTER);
}
stylePane = createStylePane();
setColorPaneContent(panel);
JPanel colorPane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel);
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
return panel.getComponentCount() == 0 ? null : colorPane;
}
protected JPanel createColorChoosePane() {
JPanel divideButtonPane = initDivideButtonPane();
colorDividePane = createColorDividePane();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] col = {f};
double[] row = {p, p, p, p};
Component[][] components = new Component[][]{
new Component[]{divideButtonPane},
new Component[]{colorDividePane}
};
return TableLayoutHelper.createCommonTableLayoutPane(components, row, col, 0);
}
private JPanel initDivideButtonPane() {
colorDivideButton = createDivideButton();
colorDivideButton.addActionListener(e -> checkCardPane());
colorDivideButton.setSelectedIndex(0);
UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color_Divide"));
Component[][] labelComponent = new Component[][]{
new Component[]{label, colorDivideButton},
};
JPanel gapTableLayoutPane = TableLayout4VanChartHelper.createGapTableLayoutPane(labelComponent);
gapTableLayoutPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
return gapTableLayoutPane;
}
protected abstract UIButtonGroup<String> createDivideButton();
protected abstract JPanel createColorDividePane();
protected void checkCardPane() {
CardLayout cardLayout = (CardLayout) colorDividePane.getLayout();
cardLayout.show(colorDividePane, String.valueOf(colorDivideButton.getSelectedItem()));
colorDividePane.validate();
colorDividePane.repaint();
}
}

113
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeBeautyPane.java

@ -0,0 +1,113 @@
package com.fr.van.chart.gauge;
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 com.fr.van.chart.designer.component.VanChartBeautyPane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2021-05-20
*/
public class VanChartGaugeBeautyPane extends VanChartBeautyPane {
private FixedGradientBar colorGradient;
private JPanel gradientBarPane;
public VanChartGaugeBeautyPane() {
super();
this.add(initGradientBarPane(), BorderLayout.SOUTH);
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
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();
}
});
}
protected String labelName() {
return Toolkit.i18nText("Fine-Design_Chart_Color_Style");
}
private void checkGradientBarVisible() {
gradientBarPane.setVisible(getGradientTypeBox().getSelectedIndex() == 1);
}
protected String[] getNameArray() {
return new String[]{
Toolkit.i18nText("Fine-Design_Chart_Solid_Color"),
Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"),
};
}
public void populateBean(GradientStyle gradientStyle) {
super.populateBean(gradientStyle);
if (gradientStyle.getGradientType() == GradientType.CUSTOM) {
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor());
}
checkGradientBarVisible();
}
@Override
public GradientStyle updateBean() {
GradientStyle gradientStyle = super.updateBean();
if (gradientStyle.getGradientType() == GradientType.CUSTOM) {
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner());
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner());
}
return gradientStyle;
}
protected int convertGradientTypeToIndex(GradientType gradientType) {
switch (gradientType) {
case CUSTOM:
return 1;
default:
return 0;
}
}
protected GradientType convertIndexToGradientType(int index) {
switch (index) {
case 1:
return GradientType.CUSTOM;
default:
return GradientType.AUTO;
}
}
}

230
designer-chart/src/main/java/com/fr/van/chart/gauge/VanChartGaugeSeriesPane.java

@ -1,5 +1,7 @@
package com.fr.van.chart.gauge;
import com.fr.chart.base.AttrFillStyle;
import com.fr.chart.base.GradientStyle;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.design.gui.frpane.UINumberDragPane;
@ -12,7 +14,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartStylePane;
import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithFormula;
import com.fr.design.mainframe.chart.gui.style.series.ColorPickerPaneWithMaxMin;
import com.fr.design.mainframe.chart.gui.style.series.UIColorPickerPane;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.general.ComparatorUtils;
@ -21,15 +23,17 @@ import com.fr.plugin.chart.base.AttrLabel;
import com.fr.plugin.chart.base.AttrLabelDetail;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.plugin.chart.type.GradientType;
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.style.series.VanChartAbstractPlotSeriesPane;
import com.fr.van.chart.designer.component.VanChartFillStylePane;
import com.fr.van.chart.designer.style.series.VanChartMultiColorSeriesPane;
import javax.swing.JPanel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
@ -38,7 +42,7 @@ import java.awt.event.ActionListener;
/**
* Created by Mitisky on 15/11/27.
*/
public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
public class VanChartGaugeSeriesPane extends VanChartMultiColorSeriesPane {
private static final long serialVersionUID = -4414343926082129759L;
private UIButtonGroup gaugeLayout;//布局:横向、纵向
@ -61,6 +65,10 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private UISpinner thermometerWidth;
private UINumberDragPane chutePercent;
private VanChartFillStylePane valueFillStylePane;
private JPanel colorChoosePane;
public VanChartGaugeSeriesPane(ChartStylePane parent, Plot plot) {
super(parent, plot);
}
@ -71,16 +79,86 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH;
double[] columnSize = {f};
//TODO Bjorn
double[] rowSize = {p,p,p,p,p,p,p};
double[] rowSize = {p, p, p, p, p, p, p};
Component[][] components = new Component[][]{
new Component[]{createGaugeLayoutPane()},
new Component[]{createGaugeStylePane(rowSize, new double[]{f,e})},
new Component[]{createGaugeStylePane(rowSize, new double[]{f, e})},
new Component[]{createGaugeBandsPane()}
};
return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
protected JPanel createColorChoosePane() {
vanChartFillStylePane = getVanChartFillStylePane();
GaugeStyle style = getGaugeStyle();
switch (style) {
case RING:
case SLOT:
case THERMOMETER:
colorChoosePane = super.createColorChoosePane();
break;
default:
colorChoosePane = vanChartFillStylePane;
break;
}
return colorChoosePane;
}
protected void checkFillStylePane(GradientStyle gradientStyle) {
if (colorChoosePane != null) {
colorChoosePane.setVisible(gradientStyle.getGradientType() != GradientType.CUSTOM);
}
}
protected UIButtonGroup<String> createDivideButton() {
return new UIButtonGroup<>(new String[]{
Toolkit.i18nText("Fine-Design_Chart_Style_Category"),
Toolkit.i18nText("Fine-Design_Chart_Use_Value")
}, new String[]{"category", "value"});
}
protected JPanel createColorDividePane() {
JPanel panel = new JPanel(new BorderLayout(0, 0));
valueFillStylePane = getVanChartFillStylePane();
JPanel stylePane = valueFillStylePane == null ? new JPanel() : valueFillStylePane;
colorPickerPane = new ColorPickerPaneWithMaxMin(parentPane, "meterString", valueFillStylePane) {
protected int getBoundX() {
return 0;
}
protected int getBoundY() {
return 10;
}
protected double getDescriptionWidth() {
double descriptionWidth = super.getDescriptionWidth();
if (valueFillStylePane == null) {
descriptionWidth += 3;
}
return descriptionWidth;
}
};
panel.add(colorPickerPane, BorderLayout.NORTH);
panel.add(stylePane, BorderLayout.CENTER);
JPanel categoryFillPane = vanChartFillStylePane == null ? new JPanel() : vanChartFillStylePane;
JPanel colorDividePane = new JPanel(new CardLayout()) {
@Override
public Dimension getPreferredSize() {
if (getColorDivideButton().getSelectedIndex() == 0) {
return categoryFillPane.getPreferredSize();
} else {
return panel.getPreferredSize();
}
}
};
colorDividePane.add(categoryFillPane, "category");
colorDividePane.add(panel, "value");
return colorDividePane;
}
private JPanel createGaugeLayoutPane() {
gaugeLayout = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Direction_Horizontal"), Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical")});
@ -105,20 +183,20 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
}
private void changeLabelPosition() {
if(plot instanceof VanChartGaugePlot){
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot;
if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)){
if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
if (ComparatorUtils.equals(gaugePlot.getGaugeStyle(), GaugeStyle.THERMOMETER)) {
ConditionAttr attrList = gaugePlot.getConditionCollection().getDefaultAttr();
AttrLabel attrLabel = (AttrLabel)attrList.getExisted(AttrLabel.class);
if(attrLabel == null){
AttrLabel attrLabel = (AttrLabel) attrList.getExisted(AttrLabel.class);
if (attrLabel == null) {
return;
}
AttrLabelDetail attrLabelDetail = attrLabel.getAttrLabelDetail();
if(attrLabelDetail == null || attrLabelDetail.getTextAttr() == null){
if (attrLabelDetail == null || attrLabelDetail.getTextAttr() == null) {
return;
}
attrLabelDetail.getTextAttr().setFRFont(VanChartGaugePlot.THERMOMETER_LABEL_FONT);
if(gaugeLayout.getSelectedIndex() == 0){
if (gaugeLayout.getSelectedIndex() == 0) {
attrLabel.getAttrLabelDetail().setPosition(Constants.LEFT);
attrLabel.getGaugeValueLabelDetail().setPosition(Constants.LEFT);
} else {
@ -133,7 +211,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
JPanel panel = new JPanel(new BorderLayout(0, 6));
JPanel centerPanel = TableLayoutHelper.createTableLayoutPane(getDiffComponentsWithGaugeStyle(), row, col);
panel.add(centerPanel, BorderLayout.CENTER);
if(rotate != null){
if (rotate != null) {
JPanel panel1 = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Rotation_Direction"), rotate);
panel.add(panel1, BorderLayout.NORTH);
}
@ -141,7 +219,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
}
private Component[][] getDiffComponentsWithGaugeStyle() {
GaugeStyle style = plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot)plot).getGaugeStyle();
GaugeStyle style = getGaugeStyle();
switch (style) {
//TODO Bjorn 仪表盘样式自动逻辑
case RING:
@ -149,8 +227,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
return new Component[][]{
new Component[]{null, null},
getPaneBackgroundColor(),
/* getPaneBackgroundColorAuto(),
new Component[]{null, paneBackgroundColor},*/
/* getPaneBackgroundColorAuto(),
new Component[]{null, paneBackgroundColor},*/
getInnerPaneBackgroundColor(),
new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null},
getChutePercent()
@ -160,8 +238,8 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
new Component[]{null, null},
getNeedleColor(),
getSlotBackgroundColor(),
/* getSlotBackgroundColorAuto(),
new Component[]{null, slotBackgroundColor},*/
/* getSlotBackgroundColorAuto(),
new Component[]{null, slotBackgroundColor},*/
new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null},
getChutePercent()
};
@ -179,13 +257,13 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
return new Component[][]{
new Component[]{null, null},
getHingeColor(),
/* getHingeColorAuto(),
new Component[]{null, hingeColor},*/
/* getHingeColorAuto(),
new Component[]{null, hingeColor},*/
getHingeBackgroundColor(),
getNeedleColor(),
getPaneBackgroundColor(),
/* getPaneBackgroundColorAuto(),
new Component[]{null, paneBackgroundColor},*/
/* getPaneBackgroundColorAuto(),
new Component[]{null, paneBackgroundColor},*/
new Component[]{createRadiusPane(Toolkit.i18nText("Fine-Design_Chart_Radius_Set")), null}
};
}
@ -212,12 +290,12 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getHingeBackgroundColor() {
hingeBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")),hingeBackgroundColor};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Hinge_Background")), hingeBackgroundColor};
}
private Component[] getNeedleColor() {
needleColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")),needleColor};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Needle")), needleColor};
}
private Component[] getPaneBackgroundColorAuto() {
@ -236,7 +314,7 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getPaneBackgroundColor() {
paneBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")),paneBackgroundColor};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Pane_Background")), paneBackgroundColor};
}
private Component[] getSlotBackgroundColorAuto() {
@ -255,17 +333,17 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getSlotBackgroundColor() {
slotBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")),slotBackgroundColor};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Slot_Background")), slotBackgroundColor};
}
private Component[] getThermometerWidth() {
thermometerWidth = new UISpinnerWithPx(0, Double.MAX_VALUE, 0.1, 10);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Thermometer_Width")),thermometerWidth};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Thermometer_Width")), thermometerWidth};
}
private Component[] getChutePercent() {
chutePercent = new UINumberDragPaneWithPercent(0, 100, 1);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Chute_Percent")),chutePercent};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Chute_Percent")), chutePercent};
}
private void initRotate() {
@ -274,12 +352,16 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
private Component[] getInnerPaneBackgroundColor() {
innerPaneBackgroundColor = new ColorSelectBox(120);
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")),innerPaneBackgroundColor};
return new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Inner_Pane_Background")), innerPaneBackgroundColor};
}
private JPanel createGaugeBandsPane() {
colorPickerPane = new ColorPickerPaneWithFormula(parentPane, "meterString");
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Range"), colorPickerPane);
GaugeStyle gaugeStyle = getGaugeStyle();
if (gaugeStyle == GaugeStyle.POINTER || gaugeStyle == GaugeStyle.POINTER_SEMI) {
colorPickerPane = new ColorPickerPaneWithMaxMin(parentPane, "meterString");
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Range"), colorPickerPane);
}
return null;
}
private void checkHingeColorAutoButton() {
@ -298,12 +380,12 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
}
public void populateBean(Plot plot) {
if(plot == null) {
if (plot == null) {
return;
}
super.populateBean(plot);
if(plot instanceof VanChartGaugePlot){
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot;
if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle();
gaugeLayout.setSelectedIndex(detailStyle.isHorizontalLayout() ? 0 : 1);
@ -319,46 +401,53 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
slotBackgroundColorAuto.setSelectedIndex(detailStyle.isSlotBackgroundColorAuto() ? 0 : 1);
checkSlotBackgroundColorAutoButton();
}
if(hingeColor != null){
if (hingeColor != null) {
hingeColor.setSelectObject(detailStyle.getHingeColor());
}
if(hingeBackgroundColor != null){
if (hingeBackgroundColor != null) {
hingeBackgroundColor.setSelectObject(detailStyle.getHingeBackgroundColor());
}
if(needleColor != null){
if (needleColor != null) {
needleColor.setSelectObject(detailStyle.getNeedleColor());
}
if(paneBackgroundColor != null){
if (paneBackgroundColor != null) {
paneBackgroundColor.setSelectObject(detailStyle.getPaneBackgroundColor());
}
if(slotBackgroundColor != null){
if (slotBackgroundColor != null) {
slotBackgroundColor.setSelectObject(detailStyle.getSlotBackgroundColor());
}
if(rotate != null){
if (rotate != null) {
rotate.setSelectedIndex(detailStyle.isAntiClockWise() ? 0 : 1);
}
if(innerPaneBackgroundColor != null){
if (innerPaneBackgroundColor != null) {
innerPaneBackgroundColor.setSelectObject(detailStyle.getInnerPaneBackgroundColor());
}
if(thermometerWidth != null){
if (thermometerWidth != null) {
thermometerWidth.setValue(detailStyle.getThermometerWidth());
}
if(chutePercent != null){
if (chutePercent != null) {
chutePercent.populateBean(detailStyle.getChutePercent());
}
if (getColorDivideButton() != null) {
getColorDivideButton().setSelectedIndex(detailStyle.isColorUseCategory() ? 0 : 1);
checkCardPane();
}
colorPickerPane.populateBean(detailStyle.getHotAreaColor());
if (valueFillStylePane != null) {
valueFillStylePane.populateBean(plot.getPlotFillStyle());
}
}
}
@Override
public void updateBean(Plot plot) {
if(plot == null){
if (plot == null) {
return;
}
super.updateBean(plot);
if(plot instanceof VanChartGaugePlot){
VanChartGaugePlot gaugePlot = (VanChartGaugePlot)plot;
if (plot instanceof VanChartGaugePlot) {
VanChartGaugePlot gaugePlot = (VanChartGaugePlot) plot;
GaugeDetailStyle detailStyle = gaugePlot.getGaugeDetailStyle();
detailStyle.setHorizontalLayout(gaugeLayout.getSelectedIndex() == 0);
@ -372,40 +461,65 @@ public class VanChartGaugeSeriesPane extends VanChartAbstractPlotSeriesPane {
if (slotBackgroundColorAuto != null) {
detailStyle.setSlotBackgroundColorAuto(slotBackgroundColorAuto.getSelectedIndex() == 0);
}
if(hingeColor != null){
if (hingeColor != null) {
detailStyle.setHingeColor(hingeColor.getSelectObject());
}
if(hingeBackgroundColor != null){
if (hingeBackgroundColor != null) {
detailStyle.setHingeBackgroundColor(hingeBackgroundColor.getSelectObject());
}
if(needleColor != null){
if (needleColor != null) {
detailStyle.setNeedleColor(needleColor.getSelectObject());
}
if(paneBackgroundColor != null){
if (paneBackgroundColor != null) {
detailStyle.setPaneBackgroundColor(paneBackgroundColor.getSelectObject());
}
if(slotBackgroundColor != null){
if (slotBackgroundColor != null) {
detailStyle.setSlotBackgroundColor(slotBackgroundColor.getSelectObject());
}
if(rotate != null){
if (rotate != null) {
detailStyle.setAntiClockWise(rotate.getSelectedIndex() == 0);
}
if(innerPaneBackgroundColor != null){
if (innerPaneBackgroundColor != null) {
detailStyle.setInnerPaneBackgroundColor(innerPaneBackgroundColor.getSelectObject());
}
if(thermometerWidth != null){
if (thermometerWidth != null) {
detailStyle.setThermometerWidth(thermometerWidth.getValue());
}
if(chutePercent != null){
if (chutePercent != null) {
detailStyle.setChutePercent(chutePercent.updateBean());
}
colorPickerPane.updateBean(detailStyle.getHotAreaColor());
if (getColorDivideButton() != null) {
int selectedIndex = getColorDivideButton().getSelectedIndex();
detailStyle.setColorUseCategory(selectedIndex == 0);
}
if (!detailStyle.isColorUseCategory()) {
if (valueFillStylePane != null) {
AttrFillStyle plotFillStyle = plot.getPlotFillStyle();
if (plotFillStyle == null) {
plotFillStyle = new AttrFillStyle();
plot.setPlotFillStyle(plotFillStyle);
}
valueFillStylePane.updateBean(plotFillStyle);
}
}
}
}
@Override
protected VanChartBeautyPane createStylePane() {
return null;
protected VanChartGaugeBeautyPane createStylePane() {
GaugeStyle gaugeStyle = getGaugeStyle();
switch (gaugeStyle) {
case POINTER:
case POINTER_SEMI:
return null;
default:
return new VanChartGaugeBeautyPane();
}
}
private GaugeStyle getGaugeStyle() {
return plot == null ? GaugeStyle.POINTER : ((VanChartGaugePlot) plot).getGaugeStyle();
}
}
Loading…
Cancel
Save