hades
4 years ago
40 changed files with 1233 additions and 536 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,83 @@
|
||||
package com.fr.van.chart.box; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.plugin.chart.base.AttrBorderWithWidth; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.component.background.VanChartMarkerBackgroundPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
|
||||
public class VanChartBoxBorderPane extends BasicBeanPane<AttrBorderWithWidth> { |
||||
|
||||
private VanChartMarkerBackgroundPane colorBackground; |
||||
private UISpinner lineWidth; |
||||
|
||||
public VanChartBoxBorderPane() { |
||||
colorBackground = new VanChartMarkerBackgroundPane() { |
||||
|
||||
protected Component[][] getPaneComponents() { |
||||
return new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), typeComboBox}, |
||||
new Component[]{null, centerPane}, |
||||
}; |
||||
} |
||||
}; |
||||
lineWidth = new UISpinner(0.5, Double.MAX_VALUE, 0.5, 0.5); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Line_Width")), lineWidth}, |
||||
new Component[]{colorBackground, null} |
||||
}; |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p, p}; |
||||
|
||||
JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(panel, BorderLayout.CENTER); |
||||
} |
||||
|
||||
public void populateBean(AttrBorderWithWidth border) { |
||||
if (border.getBorderColor() != null) { |
||||
this.colorBackground.populate(ColorBackground.getInstance(border.getBorderColor())); |
||||
} |
||||
|
||||
this.lineWidth.setValue(border.getLineWidth()); |
||||
} |
||||
|
||||
public AttrBorderWithWidth updateBean() { |
||||
AttrBorderWithWidth border = new AttrBorderWithWidth(); |
||||
|
||||
ColorBackground colorBackground = this.colorBackground.update(); |
||||
|
||||
if (colorBackground == null) { |
||||
border.setBorderColor(null); |
||||
} else { |
||||
border.setBorderColor(colorBackground.getColor()); |
||||
} |
||||
|
||||
if (this.lineWidth != null) { |
||||
border.setLineWidth(this.lineWidth.getValue()); |
||||
} |
||||
|
||||
return border; |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.fr.van.chart.box.condition; |
||||
|
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.base.AttrBorderWithWidth; |
||||
import com.fr.van.chart.box.VanChartBoxBorderPane; |
||||
import com.fr.van.chart.designer.other.condition.item.AbstractNormalMultiLineConditionPane; |
||||
|
||||
import javax.swing.JPanel; |
||||
|
||||
public class VanChartBoxBorderConditionPane extends AbstractNormalMultiLineConditionPane { |
||||
private VanChartBoxBorderPane borderPane; |
||||
|
||||
protected JPanel initContentPane() { |
||||
borderPane = new VanChartBoxBorderPane(); |
||||
return borderPane; |
||||
} |
||||
|
||||
public VanChartBoxBorderConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||
super(conditionAttributesPane); |
||||
} |
||||
|
||||
public String nameForPopupMenuItem() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Border"); |
||||
} |
||||
|
||||
protected String getItemLabelString() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
public void setDefault() { |
||||
borderPane.populateBean(new AttrBorderWithWidth()); |
||||
} |
||||
|
||||
public void populate(DataSeriesCondition condition) { |
||||
if (condition instanceof AttrBorderWithWidth) { |
||||
this.borderPane.populateBean((AttrBorderWithWidth) condition); |
||||
} |
||||
} |
||||
|
||||
public DataSeriesCondition update() { |
||||
return this.borderPane.updateBean(); |
||||
} |
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.fr.van.chart.box.condition; |
||||
|
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.base.VanChartAttrMarker; |
||||
import com.fr.plugin.chart.box.VanChartAttrNormalMarker; |
||||
import com.fr.plugin.chart.marker.type.MarkerType; |
||||
import com.fr.van.chart.designer.component.VanChartMarkerPane; |
||||
import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; |
||||
|
||||
public class VanChartBoxNormalMarkerConditionPane extends VanChartMarkerConditionPane { |
||||
|
||||
public VanChartBoxNormalMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||
super(conditionAttributesPane); |
||||
} |
||||
|
||||
public String nameForPopupMenuItem() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Normal_Value"); |
||||
} |
||||
|
||||
protected String getItemLabelString() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
protected void initMarkerPane() { |
||||
markerPane = new VanChartMarkerPane() { |
||||
|
||||
protected VanChartAttrMarker createNewAttrMarker() { |
||||
return new VanChartAttrNormalMarker(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void setDefault() { |
||||
VanChartAttrNormalMarker normalMarker = new VanChartAttrNormalMarker(); |
||||
normalMarker.setMarkerType(MarkerType.MARKER_CIRCLE); |
||||
|
||||
markerPane.populate(new VanChartAttrNormalMarker()); |
||||
} |
||||
|
||||
public void populate(DataSeriesCondition condition) { |
||||
if (condition instanceof VanChartAttrNormalMarker) { |
||||
markerPane.populate((VanChartAttrNormalMarker) condition); |
||||
} |
||||
} |
||||
|
||||
public DataSeriesCondition update() { |
||||
return markerPane.update(); |
||||
} |
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.fr.van.chart.box.condition; |
||||
|
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.base.VanChartAttrMarker; |
||||
import com.fr.plugin.chart.box.VanChartAttrOutlierMarker; |
||||
import com.fr.plugin.chart.marker.type.MarkerType; |
||||
import com.fr.van.chart.designer.component.VanChartMarkerPane; |
||||
import com.fr.van.chart.designer.other.condition.item.VanChartMarkerConditionPane; |
||||
|
||||
public class VanChartBoxOutlierMarkerConditionPane extends VanChartMarkerConditionPane { |
||||
|
||||
public VanChartBoxOutlierMarkerConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||
super(conditionAttributesPane); |
||||
} |
||||
|
||||
public String nameForPopupMenuItem() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"); |
||||
} |
||||
|
||||
protected String getItemLabelString() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
public void setDefault() { |
||||
VanChartAttrOutlierMarker outlierMarker = new VanChartAttrOutlierMarker(); |
||||
outlierMarker.setMarkerType(MarkerType.MARKER_CIRCLE_HOLLOW); |
||||
|
||||
markerPane.populate(outlierMarker); |
||||
} |
||||
|
||||
protected void initMarkerPane() { |
||||
markerPane = new VanChartMarkerPane() { |
||||
|
||||
protected VanChartAttrMarker createNewAttrMarker() { |
||||
return new VanChartAttrOutlierMarker(); |
||||
} |
||||
}; |
||||
} |
||||
|
||||
public void populate(DataSeriesCondition condition) { |
||||
if (condition instanceof VanChartAttrOutlierMarker) { |
||||
markerPane.populate((VanChartAttrOutlierMarker) condition); |
||||
} |
||||
} |
||||
|
||||
public DataSeriesCondition update() { |
||||
return markerPane.update(); |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue