Henry.Wang
4 years ago
26 changed files with 809 additions and 362 deletions
@ -0,0 +1,73 @@
|
||||
package com.fr.design.formula; |
||||
|
||||
import com.fr.base.BaseFormula; |
||||
import com.fr.design.gui.itextfield.DictionaryTextField; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.text.Document; |
||||
|
||||
/** |
||||
* 公式展示时使用。 |
||||
* 展示 String. |
||||
* 但实际保存的是 BaseFormula。 |
||||
* 从而保留公式的形态。 |
||||
* |
||||
* created by Harrison on 2020/08/03 |
||||
**/ |
||||
public class FormulaTextField extends DictionaryTextField<BaseFormula> { |
||||
|
||||
private static final BaseFormula EMPTY_FORMULA = BaseFormula.createFormulaBuilder().build("="); |
||||
|
||||
public FormulaTextField() { |
||||
} |
||||
|
||||
public FormulaTextField(int columns) { |
||||
super(columns); |
||||
} |
||||
|
||||
public FormulaTextField(String text, int columns, BaseFormula value) { |
||||
super(text, columns, value); |
||||
} |
||||
|
||||
public FormulaTextField(String text, BaseFormula value) { |
||||
super(text, value); |
||||
} |
||||
|
||||
public FormulaTextField(Document doc, String text, int columns, BaseFormula value) { |
||||
super(doc, text, columns, value); |
||||
} |
||||
|
||||
@Override |
||||
public BaseFormula getValue() { |
||||
|
||||
if (this.value == null) { |
||||
this.value = createDefault(); |
||||
} |
||||
return this.value; |
||||
} |
||||
|
||||
/** |
||||
* 设置值时,会将展示的公式值一同设置进去 |
||||
* |
||||
* @param value 公式值 |
||||
*/ |
||||
@Override |
||||
public void setValue(BaseFormula value) { |
||||
|
||||
this.value = value; |
||||
if (this.value == null) { |
||||
this.value = createDefault(); |
||||
} |
||||
setText(this.value.getPureContent()); |
||||
} |
||||
|
||||
private BaseFormula createDefault() { |
||||
|
||||
String text = getText(); |
||||
if (StringUtils.isNotEmpty(text)) { |
||||
return BaseFormula.createFormulaBuilder().build(text); |
||||
} else { |
||||
return EMPTY_FORMULA; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
package com.fr.design.gui.itextfield; |
||||
|
||||
import javax.swing.text.Document; |
||||
|
||||
/** |
||||
* 文字 ui. |
||||
* 保存实际值,展示值。 |
||||
* 允许实际值和展示值不同。 |
||||
* |
||||
* created by Harrison on 2020/08/03 |
||||
**/ |
||||
public class DictionaryTextField<T> extends UITextField { |
||||
|
||||
protected T value; |
||||
|
||||
public DictionaryTextField() { |
||||
} |
||||
|
||||
public DictionaryTextField(int columns) { |
||||
super(columns); |
||||
} |
||||
|
||||
public DictionaryTextField(String text, int columns, T value) { |
||||
super(text, columns); |
||||
this.value = value; |
||||
} |
||||
|
||||
public DictionaryTextField(String text, T value) { |
||||
super(text); |
||||
this.value = value; |
||||
} |
||||
|
||||
public DictionaryTextField(Document doc, String text, int columns, T value) { |
||||
super(doc, text, columns); |
||||
this.value = value; |
||||
} |
||||
|
||||
public T getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public void setValue(T value) { |
||||
this.value = value; |
||||
} |
||||
} |
@ -0,0 +1,74 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; |
||||
import com.fr.design.gui.frpane.UINumberDragPane; |
||||
import com.fr.design.gui.ilable.BoldFontTextLabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; |
||||
import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; |
||||
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||
import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick; |
||||
import com.fr.van.chart.range.component.GradualIntervalConfigPane; |
||||
import com.fr.van.chart.range.component.GradualLegendPane; |
||||
import com.fr.van.chart.range.component.LegendGradientBar; |
||||
import com.fr.van.chart.range.component.SectionIntervalConfigPaneWithOutNum; |
||||
import com.fr.van.chart.range.component.SectionLegendPane; |
||||
|
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-08-04 |
||||
*/ |
||||
public class VanChartHeatValueColorPane extends VanChartValueColorPane { |
||||
|
||||
public VanChartHeatValueColorPane(VanChartStylePane parent) { |
||||
super(parent); |
||||
} |
||||
|
||||
protected GradualLegendPane createGradualLegendPane() { |
||||
return new GradualLegendPane() { |
||||
@Override |
||||
protected GradualIntervalConfigPane createGradualIntervalConfigPane() { |
||||
return new GradualIntervalConfigPane() { |
||||
@Override |
||||
protected Component[][] getPaneComponents(MinMaxValuePaneWithOutTick minMaxValuePane, ColorSelectBoxWithOutTransparent colorSelectBox, UINumberDragPane numberDragPane, LegendGradientBar legendGradientBar) { |
||||
return new Component[][]{ |
||||
new Component[]{minMaxValuePane, null}, |
||||
new Component[]{new BoldFontTextLabel(Toolkit.i18nText("Fine-Design_Chart_Value_Divided_Stage")), numberDragPane}, |
||||
new Component[]{null, legendGradientBar} |
||||
}; |
||||
} |
||||
}; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
protected SectionLegendPane createSectionLegendPane() { |
||||
return new SectionLegendPane(getVanChartStylePane()) { |
||||
@Override |
||||
protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { |
||||
return new SectionIntervalConfigPaneWithOutNum(parent) { |
||||
private static final int WIDTH = 227; |
||||
|
||||
@Override |
||||
protected int getBoundX() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
protected int getBoundY() { |
||||
return 0; |
||||
} |
||||
|
||||
@Override |
||||
protected int getBoundWidth() { |
||||
return WIDTH; |
||||
} |
||||
}; |
||||
} |
||||
}; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,153 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.design.dialog.BasicPane; |
||||
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.PaneTitleConstants; |
||||
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.style.VanChartStylePane; |
||||
import com.fr.van.chart.range.component.GradualLegendPane; |
||||
import com.fr.van.chart.range.component.SectionLegendPane; |
||||
|
||||
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 class VanChartValueColorPane extends BasicPane { |
||||
//颜色类型切换按钮
|
||||
private UIButtonGroup<LegendType> valueColorTypeButton; |
||||
|
||||
//连续渐变面板
|
||||
private GradualLegendPane gradualLegendPane; |
||||
//区域渐变面板
|
||||
private SectionLegendPane sectionLegendPane; |
||||
|
||||
private VanChartStylePane parent; |
||||
|
||||
private JPanel rangeLegendPane; |
||||
|
||||
public VanChartValueColorPane(VanChartStylePane parent) { |
||||
this.parent = parent; |
||||
initComponents(); |
||||
} |
||||
|
||||
public VanChartStylePane getVanChartStylePane() { |
||||
return parent; |
||||
} |
||||
|
||||
public void initComponents() { |
||||
valueColorTypeButton = createLegendTypeButton(); |
||||
valueColorTypeButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkCardPane(); |
||||
} |
||||
}); |
||||
valueColorTypeButton.setSelectedIndex(0); |
||||
|
||||
UILabel label = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Color_Type")); |
||||
Component[][] labelComponent = new Component[][]{ |
||||
new Component[]{label, valueColorTypeButton}, |
||||
}; |
||||
JPanel legendTypeButtonWithTilePane = TableLayout4VanChartHelper.createGapTableLayoutPane(labelComponent); |
||||
legendTypeButtonWithTilePane.setBorder(BorderFactory.createEmptyBorder(10,0,0,0)); |
||||
//渐变色图例面板
|
||||
gradualLegendPane = createGradualLegendPane(); |
||||
//区域段图例面板
|
||||
sectionLegendPane = createSectionLegendPane(); |
||||
|
||||
rangeLegendPane = new JPanel(new CardLayout()) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
if (valueColorTypeButton.getSelectedItem() == LegendType.GRADUAL) { |
||||
return gradualLegendPane.getPreferredSize(); |
||||
} else { |
||||
return sectionLegendPane.getPreferredSize(); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
rangeLegendPane.add(gradualLegendPane, LegendType.GRADUAL.getStringType()); |
||||
rangeLegendPane.add(sectionLegendPane, LegendType.SECTION.getStringType()); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double[] col = {f}; |
||||
double[] row = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{legendTypeButtonWithTilePane}, |
||||
new Component[]{rangeLegendPane} |
||||
}; |
||||
JPanel tableLayoutPane = TableLayoutHelper.createTableLayoutPane(components, row, col); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(tableLayoutPane, BorderLayout.CENTER); |
||||
} |
||||
|
||||
private void checkCardPane() { |
||||
CardLayout cardLayout = (CardLayout) rangeLegendPane.getLayout(); |
||||
cardLayout.show(rangeLegendPane, valueColorTypeButton.getSelectedItem().getStringType()); |
||||
this.validate(); |
||||
this.repaint(); |
||||
} |
||||
|
||||
private UIButtonGroup<LegendType> createLegendTypeButton() { |
||||
return new UIButtonGroup<>(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Continuous_Gradient"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Area_Gradient") |
||||
}, new LegendType[]{LegendType.GRADUAL, LegendType.SECTION}); |
||||
} |
||||
|
||||
protected GradualLegendPane createGradualLegendPane() { |
||||
return new GradualLegendPane(); |
||||
} |
||||
|
||||
protected SectionLegendPane createSectionLegendPane() { |
||||
return new SectionLegendPane(parent); |
||||
} |
||||
|
||||
/** |
||||
* 标题 |
||||
* |
||||
* @return 标题 |
||||
*/ |
||||
public String title4PopupWindow() { |
||||
return PaneTitleConstants.CHART_STYLE_SERIES_TITLE; |
||||
} |
||||
|
||||
public void updateBean(VanChartRangeLegend legend) { |
||||
LegendType legendType = valueColorTypeButton.getSelectedItem(); |
||||
legend.setLegendType(legendType); |
||||
if (legendType == LegendType.GRADUAL) { |
||||
gradualLegendPane.update(legend.getGradualLegend()); |
||||
} else if (legendType == LegendType.SECTION) { |
||||
sectionLegendPane.update(legend.getSectionLegend()); |
||||
} |
||||
} |
||||
|
||||
public void populateBean(VanChartRangeLegend legend) { |
||||
//范围图例部分
|
||||
if (legend.getLegendType() != LegendType.ORDINARY) { |
||||
valueColorTypeButton.setSelectedItem(legend.getLegendType()); |
||||
} |
||||
gradualLegendPane.populate(legend.getGradualLegend()); |
||||
sectionLegendPane.populate(legend.getSectionLegend()); |
||||
checkCardPane(); |
||||
} |
||||
} |
@ -0,0 +1,173 @@
|
||||
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; |
||||
|
||||
private VanChartValueColorPane vanChartValueColorPane; |
||||
|
||||
private JPanel colorDividePane; |
||||
|
||||
public VanChartColorValueSeriesPane(ChartStylePane parent, Plot plot) { |
||||
super(parent, plot); |
||||
} |
||||
|
||||
|
||||
public VanChartValueColorPane getVanChartValueColorPane() { |
||||
return vanChartValueColorPane; |
||||
} |
||||
|
||||
public void setVanChartValueColorPane(VanChartValueColorPane vanChartValueColorPane) { |
||||
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 null; |
||||
} |
||||
|
||||
private JPanel initDivideButtonPane() { |
||||
colorDivideButton = 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() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent 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; |
||||
} |
||||
|
||||
private void checkCardPane() { |
||||
CardLayout cardLayout = (CardLayout) colorDividePane.getLayout(); |
||||
cardLayout.show(colorDividePane, colorDivideButton.getSelectedItem()); |
||||
colorDividePane.validate(); |
||||
colorDividePane.repaint(); |
||||
} |
||||
|
||||
//风格
|
||||
protected VanChartBeautyPane createStylePane() { |
||||
return null; |
||||
} |
||||
|
||||
/** |
||||
* 保存 系列界面的属性到Plot |
||||
*/ |
||||
public void updateBean(Plot plot) { |
||||
if (plot == null) { |
||||
return; |
||||
} |
||||
super.updateBean(plot); |
||||
if (colorDivideButton != null) { |
||||
VanChartRangeLegend legend = (VanChartRangeLegend) plot.getLegend(); |
||||
int selectedIndex = colorDivideButton.getSelectedIndex(); |
||||
if (selectedIndex == 0) { |
||||
legend.setLegendType(LegendType.ORDINARY); |
||||
} else { |
||||
vanChartValueColorPane.updateBean(legend); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 更新Plot的属性到系列界面 |
||||
*/ |
||||
public void populateBean(Plot plot) { |
||||
if (plot == null) { |
||||
return; |
||||
} |
||||
super.populateBean(plot); |
||||
if (colorDivideButton != null) { |
||||
VanChartRangeLegend legend = (VanChartRangeLegend) plot.getLegend(); |
||||
LegendType legendType = legend.getLegendType(); |
||||
if (legendType == LegendType.ORDINARY) { |
||||
colorDivideButton.setSelectedIndex(0); |
||||
} else { |
||||
colorDivideButton.setSelectedIndex(1); |
||||
} |
||||
vanChartValueColorPane.populateBean(legend); |
||||
checkCardPane(); |
||||
} |
||||
} |
||||
} |
Before Width: | Height: | Size: 918 B After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in new issue