Browse Source
Merge in DESIGN/design from ~BJORN/design:feature/10.0 to feature/10.0 * commit '46d77e489323f9f03c4e78e80f6df664603c35dc': CHART-19306 仪表盘配色面板修改feature/10.0
Bjorn
4 years ago
8 changed files with 547 additions and 156 deletions
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue