diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java index dcb38c14e..bebcd14e2 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataCreatorProducer.java @@ -71,28 +71,42 @@ public class TableDataCreatorProducer { } public TableDataNameObjectCreator[] createServerTableDataCreator() { - TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, + TableDataNameObjectCreator dataBase = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Database_Query"), + "ds", + "/com/fr/design/images/data/dock/serverdatabase.png", DBTableData.class, DBTableDataPane.class); - TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, + TableDataNameObjectCreator ds_Class = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Class"), + "Class", + "/com/fr/design/images/data/dock/serverclasstabledata.png", ClassTableData.class, ClassTableDataPane.class); - TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, + TableDataNameObjectCreator table = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Embedded"), + "Embedded", + "/com/fr/design/images/data/dock/serverdatatable.png", EmbeddedTableData.class, EmbeddedTableDataPane.class); - TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), "/com/fr/design/images/data/file.png", FileTableData.class, + TableDataNameObjectCreator fileTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_File"), + "File", + "/com/fr/design/images/data/file.png", FileTableData.class, FileTableDataSmallPane.class); - TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), "/com/fr/design/images/data/tree.png", + TableDataNameObjectCreator treeTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Tree"), + "Tree", + "/com/fr/design/images/data/tree.png", RecursionTableData.class, GlobalTreeTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { return true; } }; - TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), "/com/fr/design/images/data/multi.png", + TableDataNameObjectCreator multiTable = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Relation"), + "Multi", + "/com/fr/design/images/data/multi.png", ConditionTableData.class, GlobalMultiTDTableDataPane.class) { public boolean isNeedParameterWhenPopulateJControlPane() { return true; } }; - TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), "/com/fr/design/images/data/store_procedure.png", + TableDataNameObjectCreator storeProcedure = new TableDataNameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Type_Stored_Procedure"), + "Proc", + "/com/fr/design/images/data/store_procedure.png", StoreProcedure.class, ProcedureDataPane.class) { @Override public boolean shouldInsertSeparator() { diff --git a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java index 3d96ea1ef..c9eb2b621 100644 --- a/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java +++ b/designer-base/src/main/java/com/fr/design/env/RemoteWorkspace.java @@ -1,6 +1,6 @@ package com.fr.design.env; -import com.fr.cluster.engine.remote.ClusterOperator; +import com.fr.cluster.engine.rpc.remote.ClusterOperator; import com.fr.design.i18n.Toolkit; import com.fr.base.operator.common.CommonOperator; import com.fr.rpc.ExceptionHandler; diff --git a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java index 93001bde4..5041cc34a 100644 --- a/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java +++ b/designer-base/src/main/java/com/fr/design/file/TemplateTreePane.java @@ -226,6 +226,8 @@ public class TemplateTreePane extends JPanel implements FileOperations { */ @Override public void refresh() { + // 刷新远程文件夹权限 + NodeAuthProcessor.getInstance().refresh(); reportletsTree.refresh(); FineLoggerFactory.getLogger().info(Toolkit.i18nText("Fine-Design_Basic_Template_File_Tree_Refresh_Successfully") + "!"); } diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java b/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java new file mode 100644 index 000000000..146085e3d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaTextField.java @@ -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 { + + 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; + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java index 222aa90fe..4d598a7e2 100644 --- a/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/SortFormulaPane.java @@ -7,12 +7,13 @@ import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.SortOrderComboBox; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.utils.gui.GUICoreUtils; - -import javax.swing.*; -import java.awt.*; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -20,7 +21,7 @@ public abstract class SortFormulaPane extends JPanel { protected static final String InsetText = " "; protected SortOrderComboBox sortOrderComboBox; - protected UITextField sortFormulaTextField; + protected FormulaTextField sortFormulaTextField; // 屏蔽掉“自定义比较规则”和“选择”按钮,只显示公式输入文本和公式按钮 protected UIButton sortFormulaTextFieldButton; @@ -35,7 +36,7 @@ public abstract class SortFormulaPane extends JPanel { } }); - sortFormulaTextField = new UITextField(16); + sortFormulaTextField = new FormulaTextField(16); //Lance:添加一公式编辑器按钮 sortFormulaTextFieldButton = new UIButton("..."); sortFormulaTextFieldButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Formula") + "..."); @@ -55,17 +56,15 @@ public abstract class SortFormulaPane extends JPanel { public abstract void formulaAction(); public void showFormulaDialog(String[] displayNames) { - String text = sortFormulaTextField.getText(); - final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); - formulaPane.populate(BaseFormula.createFormulaBuilder().build(text), new CustomVariableResolver(displayNames, true)); + BaseFormula value = sortFormulaTextField.getValue(); + final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); + formulaPane.populate(value, new CustomVariableResolver(displayNames, true)); formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(SortFormulaPane.this), new DialogActionAdapter() { public void doOk() { BaseFormula fm = formulaPane.update(); - if (fm.getContent().length() <= 1) { - sortFormulaTextField.setText(""); - } else { - sortFormulaTextField.setText(fm.getContent().substring(1)); + if (fm != null) { + sortFormulaTextField.setValue(fm); } } }).setVisible(true); diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java new file mode 100644 index 000000000..b8805b61d --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/DictionaryTextField.java @@ -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 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; + } +} diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java index abd27f89b..efafa7cb2 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterDesignerProvider.java @@ -50,6 +50,10 @@ public interface ParameterDesignerProvider { void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex); + default int addingAllParameter2EditorWithReturnValue(Parameter[] parameterArray, int currentIndex) { + return 0; + } + JPanel[] toolbarPanes4Form(); JComponent[] toolBarButton4Form(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java index c9a6caf80..25b876033 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/series/UIColorPickerPane.java @@ -18,7 +18,6 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.style.color.ColorControlWindow; import com.fr.design.style.color.ColorSelectBox; import com.fr.design.utils.gui.GUICoreUtils; - import com.fr.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; @@ -29,6 +28,8 @@ import javax.swing.JPanel; import javax.swing.SwingConstants; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import java.util.ArrayList; +import java.util.List; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -40,8 +41,6 @@ import java.awt.LayoutManager; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; public class UIColorPickerPane extends BasicPane implements UIObserver { private static final int MARGIN_TOP = 7; @@ -635,7 +634,7 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { @Override public void layoutContainer(Container parent) { - upControlPane.setBounds(MARGIN_LEFT, MARGIN_TOP, UPCONTROLPANE_WIDTH, upControlPane.getPreferredSize().height); + upControlPane.setBounds(getBoundX(), getBoundY(), getBoundWidth(), upControlPane.getPreferredSize().height); colorGroup.setBounds(COLORGROUP_MARGIN_LEFT, 2 * MARGIN_TOP + upControlPane.getPreferredSize().height + LAYOUR_DET, colorGroup.getPreferredSize().width, colorGroup.getPreferredSize().height + upControlPane.getPreferredSize().height); textGroup.setBounds(colorGroup.getPreferredSize().width + COLORGROUP_MARGIN_LEFT, MARGIN_TOP + upControlPane.getPreferredSize().height + LAYOUR_DET, textGroup.getPreferredSize().width, textGroup.getPreferredSize().height); } @@ -646,6 +645,17 @@ public class UIColorPickerPane extends BasicPane implements UIObserver { } }; + protected int getBoundX() { + return MARGIN_LEFT; + } + + protected int getBoundY() { + return MARGIN_TOP; + } + + protected int getBoundWidth() { + return UPCONTROLPANE_WIDTH; + } /** *刷新颜色选取器 diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java new file mode 100644 index 000000000..a5a9bec1b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxBorderPane.java @@ -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 { + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java index c0412a9f3..3ae76a247 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxConditionPane.java @@ -2,15 +2,19 @@ package com.fr.van.chart.box; import com.fr.chart.base.AttrAlpha; import com.fr.chart.base.AttrBackground; -import com.fr.chart.base.AttrBorder; import com.fr.chart.chartattr.Plot; import com.fr.design.chart.series.SeriesCondition.ChartConditionPane; import com.fr.design.chart.series.SeriesCondition.DataSeriesConditionPane; import com.fr.design.chart.series.SeriesCondition.LabelAlphaPane; +import com.fr.plugin.chart.base.AttrBorderWithWidth; +import com.fr.plugin.chart.box.VanChartAttrNormalMarker; +import com.fr.plugin.chart.box.VanChartAttrOutlierMarker; import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.plugin.chart.type.ConditionKeyType; -import com.fr.van.chart.column.VanChartColumnLabelBorderPane; -import com.fr.van.chart.designer.other.condition.item.VanChartColumnSeriesColorConditionPane; +import com.fr.van.chart.box.condition.VanChartBoxBorderConditionPane; +import com.fr.van.chart.box.condition.VanChartBoxNormalMarkerConditionPane; +import com.fr.van.chart.box.condition.VanChartBoxOutlierMarkerConditionPane; +import com.fr.van.chart.designer.other.condition.item.VanChartSeriesColorConditionPane; import java.awt.Dimension; @@ -27,9 +31,14 @@ public class VanChartBoxConditionPane extends DataSeriesConditionPane { } protected void addBasicAction() { - classPaneMap.put(AttrBackground.class, new VanChartColumnSeriesColorConditionPane(this)); + classPaneMap.put(AttrBackground.class, new VanChartSeriesColorConditionPane(this)); classPaneMap.put(AttrAlpha.class, new LabelAlphaPane(this)); - classPaneMap.put(AttrBorder.class, new VanChartColumnLabelBorderPane(this)); + classPaneMap.put(AttrBorderWithWidth.class, new VanChartBoxBorderConditionPane(this)); + + if (((VanChartBoxPlot) plot).isDetailed()) { + classPaneMap.put(VanChartAttrNormalMarker.class, new VanChartBoxNormalMarkerConditionPane(this)); + classPaneMap.put(VanChartAttrOutlierMarker.class, new VanChartBoxOutlierMarkerConditionPane(this)); + } } protected void addStyleAction() { diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java index 2679f7eba..f019bc99e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxPlotPane.java @@ -3,6 +3,7 @@ package com.fr.van.chart.box; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; import com.fr.log.FineLoggerFactory; +import com.fr.plugin.chart.base.VanChartTools; import com.fr.plugin.chart.box.BoxIndependentVanChart; import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.van.chart.designer.type.AbstractVanChartTypePane; @@ -42,4 +43,9 @@ public class VanChartBoxPlotPane extends AbstractVanChartTypePane { return BoxIndependentVanChart.BoxVanChartTypes[0]; } + protected VanChartTools createVanChartTools() { + VanChartTools tools = new VanChartTools(); + tools.setSort(false); + return tools; + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java index 617d3e5e7..8f0b5480b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxSeriesPane.java @@ -9,7 +9,6 @@ import com.fr.plugin.chart.box.VanChartBoxPlot; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartBeautyPane; import com.fr.van.chart.designer.component.VanChartMarkerPane; -import com.fr.van.chart.designer.component.border.VanChartBorderPane; import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; import javax.swing.JPanel; @@ -18,6 +17,8 @@ import java.awt.Component; public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { + private VanChartBoxBorderPane boxBorderPane; + private JPanel normalMarker; private JPanel outlierMarker; @@ -36,7 +37,7 @@ public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{createBorderPane()}, + new Component[]{createBoxBorderPane()}, new Component[]{createNormalValuePane()}, new Component[]{createOutlierValuePane()} }; @@ -46,20 +47,21 @@ public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { return contentPane; } - protected VanChartBorderPane createDiffBorderPane() { - return new VanChartBorderPane(); + private JPanel createBoxBorderPane() { + boxBorderPane = new VanChartBoxBorderPane(); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), boxBorderPane); } private JPanel createNormalValuePane() { normalValuePane = new VanChartMarkerPane(); - normalMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Engine_Chart_Normal_Value"), normalValuePane); + normalMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Normal_Value"), normalValuePane); return normalMarker; } private JPanel createOutlierValuePane() { outlierValuePane = new VanChartMarkerPane(); - outlierMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Engine_Chart_Outlier_Value"), outlierValuePane); + outlierMarker = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"), outlierValuePane); return outlierMarker; } @@ -85,10 +87,13 @@ public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { super.populateBean(plot); if (plot instanceof VanChartBoxPlot) { - normalValuePane.populate(((VanChartBoxPlot) plot).getNormalValue()); - outlierValuePane.populate(((VanChartBoxPlot) plot).getOutlierValue()); + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxBorderPane.populateBean(boxPlot.getBorder()); + normalValuePane.populate(boxPlot.getNormalValue()); + outlierValuePane.populate(boxPlot.getOutlierValue()); - checkMarkerPane(((VanChartBoxPlot) plot).isDetailed()); + checkMarkerPane(boxPlot.isDetailed()); } } @@ -98,8 +103,11 @@ public class VanChartBoxSeriesPane extends VanChartAbstractPlotSeriesPane { } if (plot instanceof VanChartBoxPlot) { - ((VanChartBoxPlot) plot).setNormalValue(normalValuePane.update()); - ((VanChartBoxPlot) plot).setOutlierValue(outlierValuePane.update()); + VanChartBoxPlot boxPlot = (VanChartBoxPlot) plot; + + boxPlot.setBorder(boxBorderPane.updateBean()); + boxPlot.setNormalValue(normalValuePane.update()); + boxPlot.setOutlierValue(outlierValuePane.update()); } super.updateBean(plot); diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 870250d65..2b449785e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -62,7 +62,7 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { }; outlier = new VanChartFormatPaneWithCheckBox(parent, showOnPane) { protected String getCheckBoxText() { - return Toolkit.i18nText("Fine-Engine_Chart_Outlier_Value"); + return Toolkit.i18nText("Fine-Design_Chart_Outlier_Value"); } }; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java new file mode 100644 index 000000000..737c903d4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxBorderConditionPane.java @@ -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(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java new file mode 100644 index 000000000..017867dec --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxNormalMarkerConditionPane.java @@ -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(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java new file mode 100644 index 000000000..0c33a788c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/box/condition/VanChartBoxOutlierMarkerConditionPane.java @@ -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(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java index b43af6690..a2cf8628b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/report/BoxPlotReportDataContentPane.java @@ -37,13 +37,14 @@ public class BoxPlotReportDataContentPane extends AbstractReportDataContentPane this.add(createSeriesPane(parent), BorderLayout.CENTER); initDataTypeListener(); + checkDataPaneVisible(); } private JPanel createDataTypePane() { JPanel pane = new JPanel(new BorderLayout(4, 0)); pane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Type")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Form")); label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); String[] names = new String[]{ @@ -52,6 +53,7 @@ public class BoxPlotReportDataContentPane extends AbstractReportDataContentPane }; dataType = new UIButtonGroup(names); + dataType.setSelectedIndex(0); dataType.setPreferredSize(new Dimension(100, 20)); pane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{dataType, null, null, label, null})); diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java index cb2de668a..92b554d0d 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/data/table/BoxPlotTableDataContentPane.java @@ -54,7 +54,7 @@ public class BoxPlotTableDataContentPane extends AbstractTableDataContentPane { JPanel pane = new JPanel(new BorderLayout(4, 0)); pane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Type")); + UILabel label = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Form")); label.setPreferredSize(new Dimension(ChartDataPane.LABEL_WIDTH, ChartDataPane.LABEL_HEIGHT)); String[] names = new String[]{ @@ -63,6 +63,7 @@ public class BoxPlotTableDataContentPane extends AbstractTableDataContentPane { }; dataType = new UIButtonGroup(names); + dataType.setSelectedIndex(0); dataType.setPreferredSize(new Dimension(100, 20)); pane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{dataType, null, null, label, null})); diff --git a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java index 3ec2af314..9a4e9bc79 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/bubble/VanChartBubbleSeriesPane.java @@ -2,8 +2,8 @@ package com.fr.van.chart.bubble; import com.fr.chart.chartattr.Plot; import com.fr.chart.chartglyph.ConditionAttr; -import com.fr.design.i18n.Toolkit; import com.fr.design.beans.BasicBeanPane; +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; @@ -12,7 +12,7 @@ import com.fr.plugin.chart.bubble.attr.VanChartAttrBubble; import com.fr.van.chart.bubble.component.VanChartBubblePane; import com.fr.van.chart.custom.component.VanChartCustomAxisConditionPane; import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; +import com.fr.van.chart.designer.style.series.VanChartColorValueSeriesPane; import com.fr.van.chart.designer.style.series.VanChartStackedAndAxisListControlPane; import javax.swing.JPanel; @@ -22,7 +22,7 @@ import java.awt.Component; /** * Created by Mitisky on 16/3/31. */ -public class VanChartBubbleSeriesPane extends VanChartAbstractPlotSeriesPane { +public class VanChartBubbleSeriesPane extends VanChartColorValueSeriesPane { private static final long serialVersionUID = 5595016643808487932L; private VanChartBubblePane bubblePane; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java new file mode 100644 index 000000000..dac55c81c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHeatValueColorPane.java @@ -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; + } + }; + } + }; + } + +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java index 58d717af1..1f8b55cfb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartMarkerPane.java @@ -104,9 +104,13 @@ public class VanChartMarkerPane extends BasicPane { return Toolkit.i18nText("Fine-Design_Chart_Marker"); } + protected VanChartAttrMarker createNewAttrMarker(){ + return new VanChartAttrMarker(); + } + public void populate(VanChartAttrMarker marker) { if(marker == null){ - marker = new VanChartAttrMarker(); + marker = createNewAttrMarker(); } commonORCustom.setSelectedIndex(marker.isCommon() ? 0 : 1); if(marker.isCommon()){ @@ -120,7 +124,7 @@ public class VanChartMarkerPane extends BasicPane { } public VanChartAttrMarker update() { - VanChartAttrMarker marker = new VanChartAttrMarker(); + VanChartAttrMarker marker = createNewAttrMarker(); if(commonORCustom.getSelectedIndex() == 0){ commonMarkerPane.updateBean(marker); } else { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartValueColorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartValueColorPane.java new file mode 100644 index 000000000..c0d2ea7f4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartValueColorPane.java @@ -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 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 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(); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java index 60c535ceb..cb316dffe 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/HeatMapRangeLegendPane.java @@ -1,22 +1,6 @@ package com.fr.van.chart.designer.style; -import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; -import com.fr.design.gui.frpane.UINumberDragPane; -import com.fr.design.gui.ibutton.UIButtonGroup; -import com.fr.design.i18n.Toolkit; -import com.fr.design.gui.ilable.BoldFontTextLabel; -import com.fr.design.mainframe.chart.gui.ColorSelectBoxWithOutTransparent; -import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; -import com.fr.plugin.chart.type.LegendType; -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 javax.swing.JPanel; -import java.awt.Component; /** * Created by Mitisky on 16/10/20. @@ -35,41 +19,4 @@ public class HeatMapRangeLegendPane extends VanChartRangeLegendPane { protected JPanel createCommonLegendPane(){ return this.createLegendPaneWithoutHighlight(); } - - @Override - protected UIButtonGroup createLegendTypeButton(){ - return new UIButtonGroup(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), - Toolkit.i18nText("Fine-Design_Chart_Legend_Section") - }, new LegendType[]{LegendType.GRADUAL, LegendType.SECTION}); - } - - @Override - 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} - }; - } - }; - } - }; - } - - @Override - protected SectionLegendPane createSectionLegendPane() { - return new SectionLegendPane(this.getLegendPaneParent()) { - @Override - protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { - return new SectionIntervalConfigPaneWithOutNum(parent); - } - }; - } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java index 25ef2a15b..5fa030a28 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartRangeLegendPane.java @@ -1,24 +1,18 @@ package com.fr.van.chart.designer.style; -import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.TableLayout; -import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.attr.VanChartLegend; +import com.fr.plugin.chart.range.SectionLegend; 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.range.component.GradualLegendPane; -import com.fr.van.chart.range.component.SectionLegendPane; +import com.fr.van.chart.range.component.LegendLabelFormatPane; -import javax.swing.BorderFactory; import javax.swing.JPanel; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; /** @@ -28,87 +22,63 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { private static final long serialVersionUID = 1614283200308877353L; //散点图不同类型面板容器,容器布局管理 - private JPanel rangeLegendPane; - - //图例切换按钮 - private UIButtonGroup legendTypeButton; + private JPanel rangeLabelPane; //普通图例面板(因为普通图例没有新内容,故而为空) - private JPanel ordinaryLegendPane; - //渐变色图例面板 - private GradualLegendPane gradualLegendPane; - //区域段图例面板 - private SectionLegendPane sectionLegendPane; + private JPanel ordinaryLabelPane; + + private LegendLabelFormatPane gradualLabelFormPane; + + private LegendLabelFormatPane sectionLabelFormPane; + + private LegendType legendType; public VanChartRangeLegendPane() { super(); } - public VanChartRangeLegendPane(VanChartStylePane parent){ + + public VanChartRangeLegendPane(VanChartStylePane parent) { super(parent); } - private JPanel createRangeLegendPane() { - //普通图例面板 - ordinaryLegendPane = new JPanel(); - //渐变色图例面板 - gradualLegendPane = createGradualLegendPane(); - gradualLegendPane.setParentPane(this.getLegendPaneParent()); - //区域段图例面板 - sectionLegendPane = createSectionLegendPane(); - sectionLegendPane.setParentPane(this.getLegendPaneParent()); - - JPanel panel = new JPanel(new CardLayout()){ + + private JPanel createRangeLabelPane() { + ordinaryLabelPane = new JPanel(); + gradualLabelFormPane = new LegendLabelFormatPane(); + gradualLabelFormPane.setParentPane(this.getLegendPaneParent()); + sectionLabelFormPane = new LegendLabelFormatPane() { + @Override + protected void checkCustomLabelText() { + setCustomFormatterText(SectionLegend.DEFAULT_LABEL_FUNCTION); + } + }; + sectionLabelFormPane.setParentPane(this.getLegendPaneParent()); + + JPanel panel = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if(legendTypeButton.getSelectedItem() == LegendType.ORDINARY){ - return new Dimension(ordinaryLegendPane.getWidth(), 0); - } else if (legendTypeButton.getSelectedItem() == LegendType.GRADUAL){ - return gradualLegendPane.getPreferredSize(); - }else{ - return sectionLegendPane.getPreferredSize(); + if (legendType == LegendType.ORDINARY) { + return new Dimension(ordinaryLabelPane.getWidth(), 0); + } else if (legendType == LegendType.GRADUAL) { + return gradualLabelFormPane.getPreferredSize(); + } else { + return sectionLabelFormPane.getPreferredSize(); } } }; - panel.add(ordinaryLegendPane, LegendType.ORDINARY.getStringType()); - panel.add(gradualLegendPane, LegendType.GRADUAL.getStringType()); - panel.add(sectionLegendPane, LegendType.SECTION.getStringType()); + panel.add(ordinaryLabelPane, LegendType.ORDINARY.getStringType()); + panel.add(gradualLabelFormPane, LegendType.GRADUAL.getStringType()); + panel.add(sectionLabelFormPane, LegendType.SECTION.getStringType()); return panel; } - protected GradualLegendPane createGradualLegendPane() { - return new GradualLegendPane(); - } - - protected SectionLegendPane createSectionLegendPane() { - return new SectionLegendPane(this.getLegendPaneParent()); - } - - private JPanel createTableLayoutPaneWithTitle(String title, Component component) { - return TableLayout4VanChartHelper.createGapTableLayoutPane(title, component); - } - - protected UIButtonGroup createLegendTypeButton(){ - return new UIButtonGroup(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Legend_Ordinary"), - Toolkit.i18nText("Fine-Design_Chart_Legend_Gradual"), - Toolkit.i18nText("Fine-Design_Chart_Legend_Section") - }, new LegendType[]{LegendType.ORDINARY, LegendType.GRADUAL, LegendType.SECTION}); - } - - protected JPanel createCommonLegendPane(){ + protected JPanel createCommonLegendPane() { return super.createLegendPane(); } @Override - protected JPanel createLegendPane(){ - legendTypeButton = createLegendTypeButton(); - - initLegendTypeButtonListener(); - - JPanel legendTypeButtonWithTilePane = createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Legend_Form"), legendTypeButton); - legendTypeButtonWithTilePane.setBorder(BorderFactory.createEmptyBorder(0,5,0,0)); - - rangeLegendPane = createRangeLegendPane(); + protected JPanel createLegendPane() { + rangeLabelPane = createRangeLabelPane(); //不包含新内容的普通面板内容 JPanel commonLegendPane = this.createCommonLegendPane(); @@ -116,28 +86,17 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] col = {f}; - double[] row = {p, p, p, p}; + double[] row = {p, p}; Component[][] components = new Component[][]{ - new Component[]{legendTypeButtonWithTilePane}, - new Component[]{rangeLegendPane}, + new Component[]{rangeLabelPane}, new Component[]{commonLegendPane} }; - return TableLayoutHelper.createTableLayoutPane(components,row,col); - } - - private void initLegendTypeButtonListener() { - legendTypeButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - checkCardPane(); - checkLayoutPaneVisible(); - } - }); + return TableLayoutHelper.createTableLayoutPane(components, row, col); } private void checkCardPane() { - CardLayout cardLayout = (CardLayout) rangeLegendPane.getLayout(); - cardLayout.show(rangeLegendPane, legendTypeButton.getSelectedItem().getStringType()); + CardLayout cardLayout = (CardLayout) rangeLabelPane.getLayout(); + cardLayout.show(rangeLabelPane, legendType.getStringType()); } @Override @@ -151,47 +110,41 @@ public class VanChartRangeLegendPane extends VanChartPlotLegendPane { protected boolean isVisibleLayoutPane() { - return super.isVisibleLayoutPane() && legendTypeButton.getSelectedItem() != LegendType.GRADUAL; + return super.isVisibleLayoutPane() && legendType != LegendType.GRADUAL; } - private void checkHighlightVisible(){ + private void checkHighlightVisible() { JPanel highlightPane = this.getHighlightPane(); if (highlightPane != null) { - LegendType legendType = legendTypeButton.getSelectedItem(); highlightPane.setVisible(legendType != LegendType.GRADUAL); } } @Override public void updateBean(VanChartLegend legend) { - if(legend == null) { + if (legend == null) { legend = new VanChartRangeLegend(); } super.updateBean(legend); - VanChartRangeLegend scatterLegend = (VanChartRangeLegend)legend; + VanChartRangeLegend scatterLegend = (VanChartRangeLegend) legend; //范围图例部分 - LegendType legendType = legendTypeButton.getSelectedItem(); - scatterLegend.setLegendType(legendType); if (legendType == LegendType.GRADUAL) { - gradualLegendPane.update(scatterLegend.getGradualLegend()); - }else if (legendType == LegendType.SECTION) { - sectionLegendPane.update(scatterLegend.getSectionLegend()); + gradualLabelFormPane.update(scatterLegend.getGradualLegend().getLegendLabelFormat()); + } else if (legendType == LegendType.SECTION) { + sectionLabelFormPane.update(scatterLegend.getSectionLegend().getLegendLabelFormat()); } - - this.checkHighlightVisible(); } @Override public void populateBean(VanChartLegend legend) { - VanChartRangeLegend scatterLegend = (VanChartRangeLegend)legend; + VanChartRangeLegend scatterLegend = (VanChartRangeLegend) legend; + legendType = scatterLegend.getLegendType(); if (scatterLegend != null) { - //范围图例部分 - legendTypeButton.setSelectedItem(scatterLegend.getLegendType()); - gradualLegendPane.populate(scatterLegend.getGradualLegend()); - sectionLegendPane.populate(scatterLegend.getSectionLegend()); + gradualLabelFormPane.populate(scatterLegend.getGradualLegend().getLegendLabelFormat()); + sectionLabelFormPane.populate(scatterLegend.getSectionLegend().getLegendLabelFormat()); super.populateBean(scatterLegend); } checkAllUse(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartColorValueSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartColorValueSeriesPane.java new file mode 100644 index 000000000..34f86d020 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/series/VanChartColorValueSeriesPane.java @@ -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 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(); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java index 7c4fa4ad4..6e4309a87 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/heatmap/designer/style/VanChartHeatMapSeriesPane.java @@ -6,12 +6,16 @@ import com.fr.design.gui.frpane.UINumberDragPane; import com.fr.design.gui.ibutton.UIButtonGroup; 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.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.plugin.chart.heatmap.VanChartHeatMapPlot; +import com.fr.plugin.chart.range.VanChartRangeLegend; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartFillStylePane; +import com.fr.van.chart.designer.component.VanChartHeatValueColorPane; +import com.fr.van.chart.designer.style.VanChartStylePane; import com.fr.van.chart.map.VanChartMapSeriesPane; import javax.swing.JPanel; @@ -45,7 +49,7 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { } //设置色彩面板内容 - protected void setColorPaneContent (JPanel panel) { + protected void setColorPaneContent(JPanel panel) { panel.add(createNullValueColorPane(), BorderLayout.NORTH); panel.add(createAlphaPane(), BorderLayout.CENTER); } @@ -66,14 +70,14 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { detailPane.add(heatPointPane, "heatPointPane"); detailPane.add(backgroundAreaPane, "backgroundAreaPane"); - JPanel contentPane = new JPanel(new BorderLayout(0,6)); + JPanel contentPane = new JPanel(new BorderLayout(0, 6)); contentPane.add(group, BorderLayout.NORTH); contentPane.add(detailPane, BorderLayout.CENTER); group.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { - if(group.getSelectedIndex() == 0){ + if (group.getSelectedIndex() == 0) { layout.show(detailPane, "heatPointPane"); } else { layout.show(detailPane, "backgroundAreaPane"); @@ -84,13 +88,14 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { return contentPane; } - private JPanel createHeatPointPane(){ + private JPanel createHeatPointPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] row = {p, p, p, p, p}; double[] col = {f}; Component[][] components = new Component[][]{ + new Component[]{createHeatColorPane()}, new Component[]{createHeatPointStylePane()}, new Component[]{createOpacityPane()} }; @@ -98,9 +103,24 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { return TableLayoutHelper.createTableLayoutPane(components, row, col); } - private JPanel createHeatPointStylePane(){ - radius = new UISpinner(0,Double.MAX_VALUE,1,30); - blur = new UISpinner(0,100,1,30); + private JPanel createHeatColorPane() { + setVanChartValueColorPane(new VanChartHeatValueColorPane((VanChartStylePane) parentPane)); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] row = {p}; + double[] col = {f}; + + Component[][] components = new Component[][]{ + new Component[]{getVanChartFillStylePane()}, + }; + + JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, col); + return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Color"), panel); + } + + private JPanel createHeatPointStylePane() { + radius = new UISpinner(0, Double.MAX_VALUE, 1, 30); + blur = new UISpinner(0, 100, 1, 30); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -121,8 +141,8 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { } private JPanel createOpacityPane() { - maxOpacity = new UINumberDragPane(0,100); - minOpacity = new UINumberDragPane(0,100); + maxOpacity = new UINumberDragPane(0, 100); + minOpacity = new UINumberDragPane(0, 100); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -146,12 +166,13 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { public void populateBean(Plot plot) { super.populateBean(plot); - if(plot instanceof VanChartHeatMapPlot){ - VanChartHeatMapPlot heatMapPlot = (VanChartHeatMapPlot)plot; + if (plot instanceof VanChartHeatMapPlot) { + VanChartHeatMapPlot heatMapPlot = (VanChartHeatMapPlot) plot; radius.setValue(heatMapPlot.getRadius()); blur.setValue(heatMapPlot.getBlur()); maxOpacity.populateBean(heatMapPlot.getMaxOpacity()); minOpacity.populateBean(heatMapPlot.getMinOpacity()); + getVanChartValueColorPane().populateBean((VanChartRangeLegend) plot.getLegend()); } } @@ -163,12 +184,13 @@ public class VanChartHeatMapSeriesPane extends VanChartMapSeriesPane { public void updateBean(Plot plot) { super.updateBean(plot); - if(plot instanceof VanChartHeatMapPlot){ - VanChartHeatMapPlot heatMapPlot = (VanChartHeatMapPlot)plot; + if (plot instanceof VanChartHeatMapPlot) { + VanChartHeatMapPlot heatMapPlot = (VanChartHeatMapPlot) plot; heatMapPlot.setRadius(radius.getValue()); heatMapPlot.setBlur(blur.getValue()); heatMapPlot.setMaxOpacity(maxOpacity.updateBean()); heatMapPlot.setMinOpacity(minOpacity.updateBean()); + getVanChartValueColorPane().updateBean((VanChartRangeLegend) plot.getLegend()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java index b24e8fc33..ccc2e012e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/VanChartMapSeriesPane.java @@ -31,7 +31,7 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.border.VanChartBorderWithAlphaPane; import com.fr.van.chart.designer.component.marker.VanChartImageMarkerPane; import com.fr.van.chart.designer.other.VanChartInteractivePane; -import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; +import com.fr.van.chart.designer.style.series.VanChartColorValueSeriesPane; import com.fr.van.chart.designer.style.series.VanChartEffectPane; import com.fr.van.chart.map.designer.style.series.VanChartMapScatterMarkerPane; import com.fr.van.chart.map.line.VanChartCurvePane; @@ -52,7 +52,7 @@ import java.awt.event.ItemListener; * Created by Mitisky on 16/5/4. * 地图-系列界面 */ -public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { +public class VanChartMapSeriesPane extends VanChartColorValueSeriesPane { private static final String AREA_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Region"); private static final String POINT_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Point"); private static final String LINE_STRING = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Flow"); @@ -163,9 +163,10 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { protected JPanel getContentPane(boolean custom) { JPanel panel = new JPanel(new BorderLayout()); mapType = ((VanChartMapPlot) plot).getAllLayersMapType(); - if(mapType == MapType.CUSTOM || mapType == MapType.DRILL_CUSTOM) { - vanChartFillStylePane = getVanChartFillStylePane(); - panel.add(vanChartFillStylePane, BorderLayout.NORTH); + if (mapType == MapType.CUSTOM || mapType == MapType.DRILL_CUSTOM) { + JPanel pane = createColorChoosePane(); + pane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); + panel.add(pane, BorderLayout.NORTH); } panel.add(getContentInPlotType(), BorderLayout.CENTER); return panel; @@ -176,10 +177,10 @@ public class VanChartMapSeriesPane extends VanChartAbstractPlotSeriesPane { JPanel panel = new JPanel(new BorderLayout()); stylePane = createStylePane(); mapType = ((VanChartMapPlot) plot).getAllLayersMapType(); - if(mapType != MapType.CUSTOM && mapType != MapType.DRILL_CUSTOM) { - vanChartFillStylePane = getVanChartFillStylePane(); - if (vanChartFillStylePane != null) { - panel.add(vanChartFillStylePane, BorderLayout.NORTH); + if (mapType != MapType.CUSTOM && mapType != MapType.DRILL_CUSTOM) { + JPanel pane = createColorChoosePane(); + if (pane != null) { + panel.add(pane, BorderLayout.NORTH); } } setColorPaneContent(panel, paneType); diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualLegendPane.java index d1858fb13..88dd54790 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/GradualLegendPane.java @@ -2,68 +2,51 @@ package com.fr.van.chart.range.component; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - import com.fr.plugin.chart.range.GradualLegend; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -public class GradualLegendPane extends JPanel{ +public class GradualLegendPane extends JPanel { private static final long serialVersionUID = 1614283200308877353L; private GradualIntervalConfigPane intervalConfigPane; - private LegendLabelFormatPane labelFormPane; - public GradualLegendPane(){ + public GradualLegendPane() { initComponents(); } - public void setParentPane(VanChartStylePane parent) { - labelFormPane.setParentPane(parent); - } private void initComponents() { intervalConfigPane = createGradualIntervalConfigPane(); - JPanel intervalConfigPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Section_Config"),intervalConfigPane); - labelFormPane = new LegendLabelFormatPane(); double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] col = {f}; - double[] row = {p, p, p, p}; + double[] row = {p}; Component[][] components = new Component[][]{ - new Component[]{null}, - new Component[]{intervalConfigPaneWithTitle}, - new Component[]{labelFormPane}, + new Component[]{intervalConfigPane}, }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); } protected GradualIntervalConfigPane createGradualIntervalConfigPane() { return new GradualIntervalConfigPane(); } - public void populate(GradualLegend gradualLegend){ + public void populate(GradualLegend gradualLegend) { if (intervalConfigPane != null) { intervalConfigPane.populate(gradualLegend.getGradualIntervalConfig()); } - if (labelFormPane != null) { - labelFormPane.populate(gradualLegend.getLegendLabelFormat()); - } } - public void update(GradualLegend gradualLegend){ + public void update(GradualLegend gradualLegend) { if (intervalConfigPane != null) { intervalConfigPane.update(gradualLegend.getGradualIntervalConfig()); } - if (labelFormPane != null) { - labelFormPane.update(gradualLegend.getLegendLabelFormat()); - } } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java index 79038cdd7..eec9225f5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/LegendLabelFormatPane.java @@ -21,7 +21,7 @@ import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class LegendLabelFormatPane extends JPanel{ +public class LegendLabelFormatPane extends JPanel { private static final long serialVersionUID = 1614283200308877354L; private UIButtonGroup labelFormatStyle; @@ -33,25 +33,33 @@ public class LegendLabelFormatPane extends JPanel{ htmlLabelPane.setParent(parent); } - public LegendLabelFormatPane(){ + public LegendLabelFormatPane() { labelFormatStyle = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); - labelFormat = new FormatPaneWithOutFont(); + labelFormat = new FormatPaneWithOutFont() { + @Override + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { + typePane.setBorder(BorderFactory.createEmptyBorder()); + return new Component[][]{ + new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane}, + new Component[]{null, centerPane}, + }; + } + }; htmlLabelPane = new VanChartHtmlLabelPaneWithOutWidthAndHeight(); - htmlLabelPane.setBorder(BorderFactory.createEmptyBorder(0, (int)TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL,0,0)); + htmlLabelPane.setBorder(BorderFactory.createEmptyBorder(0, (int) TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH + TableLayout4VanChartHelper.COMPONENT_INTERVAL, 0, 0)); - - centerPane = new JPanel(new CardLayout()){ + centerPane = new JPanel(new CardLayout()) { @Override public Dimension getPreferredSize() { - if(labelFormatStyle.getSelectedIndex() == 0){ + if (labelFormatStyle.getSelectedIndex() == 0) { return labelFormat.getPreferredSize(); - }else{ + } else { return htmlLabelPane.getPreferredSize(); } } }; - centerPane.add(labelFormat,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); + centerPane.add(labelFormat, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); centerPane.add(htmlLabelPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); @@ -61,11 +69,11 @@ public class LegendLabelFormatPane extends JPanel{ double[] columnSize = {f, e}; double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ - new Component[]{null,null}, + new Component[]{null, null}, new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Label_Format"), SwingConstants.LEFT), labelFormatStyle}, - new Component[]{centerPane,null}, + new Component[]{centerPane, null}, }; - JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components,rowSize,columnSize); + JPanel contentPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); labelFormatStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -74,19 +82,19 @@ public class LegendLabelFormatPane extends JPanel{ }); labelFormatStyle.setSelectedIndex(0); - JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); + JPanel panel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Use_Format"), contentPane); this.setLayout(new BorderLayout()); - this.add(panel,BorderLayout.CENTER); + this.add(panel, BorderLayout.CENTER); } private void checkCardPane(boolean populate) { - if(centerPane != null && labelFormatStyle != null){ + if (centerPane != null && labelFormatStyle != null) { CardLayout cardLayout = (CardLayout) centerPane.getLayout(); if (labelFormatStyle.getSelectedIndex() == 1) { - if(!populate) { + if (!populate) { checkCustomLabelText(); } - cardLayout.show(centerPane,com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); + cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")); } else { cardLayout.show(centerPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common")); } @@ -101,21 +109,21 @@ public class LegendLabelFormatPane extends JPanel{ } /*标签部分的更新和存储数据部分要重写*/ - public void populate(LegendLabelFormat legendLabelFormat){ + public void populate(LegendLabelFormat legendLabelFormat) { if (labelFormatStyle != null) { labelFormatStyle.setSelectedIndex(legendLabelFormat.isCommonValueFormat() ? 0 : 1); } if (labelFormat != null) { labelFormat.populateBean(legendLabelFormat.getFormat()); } - if (htmlLabelPane != null){ + if (htmlLabelPane != null) { htmlLabelPane.populate(legendLabelFormat.getHtmlLabel()); } checkCardPane(true); } - public void update(LegendLabelFormat legendLabelFormat){ + public void update(LegendLabelFormat legendLabelFormat) { if (labelFormatStyle != null) { legendLabelFormat.setCommonValueFormat(labelFormatStyle.getSelectedIndex() == 0); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java index cad289f10..a6fc4cfbe 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionIntervalConfigPaneWithOutNum.java @@ -5,9 +5,7 @@ import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.Component; @@ -38,15 +36,6 @@ public class SectionIntervalConfigPaneWithOutNum extends MapColorPickerPaneWithF }); } - @Override - protected JPanel getUpControlPane(Component[][] components) { - double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - double[] columnSize = {d, e}; - JPanel panel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, getRowSIze(), columnSize); - return panel; - } - private void setRegionVisible(boolean visible) { getRegionNumPane().setVisible(visible); numLabel.setVisible(visible); diff --git a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java index 828f40d73..f2da40728 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/range/component/SectionLegendPane.java @@ -5,18 +5,15 @@ import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.chart.gui.style.series.MapColorPickerPaneWithFormula; import com.fr.plugin.chart.range.SectionLegend; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Component; -public class SectionLegendPane extends JPanel{ +public class SectionLegendPane extends JPanel { private static final long serialVersionUID = 1614283200308877353L; private MapColorPickerPaneWithFormula intervalConfigPane; - private LegendLabelFormatPane labelFormPane; private AbstractAttrNoScrollPane parent; public SectionLegendPane(AbstractAttrNoScrollPane parent) { @@ -24,28 +21,15 @@ public class SectionLegendPane extends JPanel{ initComponents(); } - public void setParentPane(VanChartStylePane parent){ - labelFormPane.setParentPane(parent); - } - private void initComponents() { intervalConfigPane = createSectionIntervalConfigPane(this.parent); - JPanel intervalConfigPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Section_Config"), intervalConfigPane); - labelFormPane = new LegendLabelFormatPane(){ - @Override - protected void checkCustomLabelText() { - setCustomFormatterText(SectionLegend.DEFAULT_LABEL_FUNCTION); - } - }; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] col = {f}; - double[] row = {p, p, p}; + double[] row = {p}; Component[][] components = new Component[][]{ - new Component[]{null}, - new Component[]{intervalConfigPaneWithTitle}, - new Component[]{labelFormPane}, + new Component[]{intervalConfigPane}, }; JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col); @@ -55,24 +39,35 @@ public class SectionLegendPane extends JPanel{ } protected MapColorPickerPaneWithFormula createSectionIntervalConfigPane(AbstractAttrNoScrollPane parent) { - return new SectionIntervalConfigPane(parent); + return new SectionIntervalConfigPane(parent) { + private static final int WIDTH = 225; + + @Override + protected int getBoundX() { + return 0; + } + + @Override + protected int getBoundY() { + return 0; + } + + @Override + protected int getBoundWidth() { + return WIDTH; + } + }; } - public void populate(SectionLegend sectionLegend){ + public void populate(SectionLegend sectionLegend) { if (intervalConfigPane != null) { intervalConfigPane.populateBean(sectionLegend.getMapHotAreaColor()); } - if (labelFormPane != null) { - labelFormPane.populate(sectionLegend.getLegendLabelFormat()); - } } - public void update(SectionLegend sectionLegend){ + public void update(SectionLegend sectionLegend) { if (intervalConfigPane != null) { intervalConfigPane.updateBean(sectionLegend.getMapHotAreaColor()); } - if (labelFormPane != null) { - labelFormPane.update(sectionLegend.getLegendLabelFormat()); - } } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java index 98c900219..b462faa81 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterSeriesPane.java @@ -13,7 +13,7 @@ import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.VanChartLineTypePane; import com.fr.van.chart.designer.component.VanChartMarkerPane; import com.fr.van.chart.designer.component.marker.VanChartCommonMarkerPane; -import com.fr.van.chart.designer.style.series.VanChartAbstractPlotSeriesPane; +import com.fr.van.chart.designer.style.series.VanChartColorValueSeriesPane; import com.fr.van.chart.designer.style.series.VanChartStackedAndAxisListControlPane; import com.fr.van.chart.scatter.component.VanChartScatterLineTypePane; @@ -24,7 +24,7 @@ import java.awt.Component; /** * 散点图的系列界面 */ -public class VanChartScatterSeriesPane extends VanChartAbstractPlotSeriesPane { +public class VanChartScatterSeriesPane extends VanChartColorValueSeriesPane { private static final long serialVersionUID = 5595016643808487932L; public VanChartScatterSeriesPane(ChartStylePane parent, Plot plot) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java index 884e96b33..4e9c612c0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudSeriesPane.java @@ -18,8 +18,7 @@ import com.fr.general.IOUtils; import com.fr.plugin.chart.wordcloud.CloudShapeType; import com.fr.plugin.chart.wordcloud.VanChartWordCloudPlot; 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.style.series.VanChartColorValueSeriesPane; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -34,7 +33,7 @@ import java.awt.event.ItemListener; /** * Created by Mitisky on 16/11/29. */ -public class VanChartWordCloudSeriesPane extends VanChartAbstractPlotSeriesPane { +public class VanChartWordCloudSeriesPane extends VanChartColorValueSeriesPane { private static final String AUTO_FONT_SIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Auto"); private static final String CUSTOM_FONT_SIZE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Define_Size"); private static final double MAX_ROTATION = 90; @@ -228,9 +227,4 @@ public class VanChartWordCloudSeriesPane extends VanChartAbstractPlotSeriesPane } } } - - @Override - protected VanChartBeautyPane createStylePane() { - return null; - } } diff --git a/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png b/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png index c0ad22d3c..743024f72 100755 Binary files a/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png and b/designer-chart/src/main/resources/com/fr/van/chart/box.images/box.png differ diff --git a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java index a91342d4a..8956125eb 100644 --- a/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java +++ b/designer-form/src/main/java/com/fr/design/form/parameter/FormParaDesigner.java @@ -74,7 +74,7 @@ import java.util.List; public class FormParaDesigner extends FormDesigner implements ParameterDesignerProvider { private static final int NUM_IN_A_LINE = 4; private static final int H_COMPONENT_GAP = 165; - private static final int V_COMPONENT_GAP = 25; + public static final int V_COMPONENT_GAP = 25; private static final int FIRST_V_LOCATION = 35; private static final int FIRST_H_LOCATION = 90; private static final int SECOND_H_LOCATION = 170; @@ -83,7 +83,6 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP private static final int SUBMIT_BUTTON_H_LOCATION = 270; private static final int PARA_IMAGE_SHIFT_X = -4; private static final int FORM_AREA_PADDING_LEFT = 13; - private int addableRegionY; private static Image paraImage = BaseUtils.readImage("/com/fr/design/images/form/parameter.png"); @@ -413,30 +412,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP if (layoutContainer == null) { layoutContainer = new XWParameterLayout(); } - refreshAddableRegion(layoutContainer); layoutContainer.setSize(LARGE_PREFERRED_SIZE); setRootComponent(layoutContainer); } - /** - * @param layoutContainer - * @Description: 为了不覆盖以前的组件,所以要计算可以添加组件的区域 - * @return: - * @Author: Henry.Wang - * @date: 2020/7/15 15:12 - */ - public void refreshAddableRegion(XLayoutContainer layoutContainer) { - addableRegionY = 0; - for (int i = 0; i < layoutContainer.getComponentCount(); i++) { - Rectangle rectangle = layoutContainer.getComponent(i).getBounds(); - if (addableRegionY < rectangle.y + rectangle.height) { - addableRegionY = rectangle.y + rectangle.height; - } - } - int vGap = V_COMPONENT_GAP - (int) XCreator.SMALL_PREFERRED_SIZE.getHeight(); - addableRegionY = Math.max(0, addableRegionY - FIRST_V_LOCATION + (int) (XCreator.SMALL_PREFERRED_SIZE.getHeight() / 2) + vGap); - } - /** * 是否是报表的参数面板 * @@ -604,15 +583,14 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP label.setWidgetName("Label" + name); label.setWidgetValue(new WidgetValue(name + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; - int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } EditorHolder editor = new EditorHolder(parameter); xCreator = XCreatorUtils.createXCreator(editor); - x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { return false; } return true; @@ -662,23 +640,34 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP * @return 是否加入 s */ public void addingAllParameter2Editor(Parameter[] parameterArray, int currentIndex) { + addingAllParameter2EditorWithReturnValue(parameterArray, currentIndex); + } + + /** + * @param parameterArray 参数数组 + * @param currentIndex 添加所有参数前的index值 + * @Description: 添加所有的参数,并返回当前的currentIndex。此方法为addingAllParameter2Editor的兼容方法。 + * @return: 添加所有参数后的index值 + * @Author: Henry.Wang + * @date: 2020/8/5 19:40 + */ + public int addingAllParameter2EditorWithReturnValue(Parameter[] parameterArray, int currentIndex) { for (int i = 0; i < parameterArray.length; i++) { com.fr.form.ui.Label label = new com.fr.form.ui.Label(); label.setWidgetName("Label" + parameterArray[i].getName()); label.setWidgetValue(new WidgetValue(parameterArray[i].getName() + ":")); XCreator xCreator = XCreatorUtils.createXCreator(label); - int x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + FIRST_H_LOCATION; - int y = addableRegionY + FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE); - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + FIRST_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } // 每行显示5组 EditorHolder editor = new EditorHolder(parameterArray[i]); editor.setWidgetName(parameterArray[i].getName()); xCreator = XCreatorUtils.createXCreator(editor); - x = H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + SECOND_H_LOCATION; - if (!(this.autoAddComponent(xCreator, x, y))) { + if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * (currentIndex % NUM_IN_A_LINE) + + SECOND_H_LOCATION, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { break; } currentIndex++; @@ -690,9 +679,10 @@ public class FormParaDesigner extends FormDesigner implements ParameterDesignerP XCreator xCreator = XCreatorUtils.createXCreator(formSubmitButton); if (!(this.autoAddComponent(xCreator, H_COMPONENT_GAP * 3 + H_GAP, FIRST_V_LOCATION + V_COMPONENT_GAP * (currentIndex / NUM_IN_A_LINE)))) { - return; + currentIndex = ((int) Math.ceil((currentIndex + 1) / (double) NUM_IN_A_LINE)) * NUM_IN_A_LINE; } } + return currentIndex; } /** diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 0941b4b22..07eefdd2b 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -7,6 +7,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.FormulaTextField; import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; @@ -25,8 +26,17 @@ import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.SelectCount; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -221,7 +231,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { + if (!(value instanceof DSColumn)) { return; } @@ -238,7 +248,7 @@ public class DSColumnAdvancedPane extends BasicPane { this.cellElement = cellElement; Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { + if (!(value instanceof DSColumn)) { return; } DSColumn dSColumn = (DSColumn) value; @@ -246,8 +256,8 @@ public class DSColumnAdvancedPane extends BasicPane { int sort = dSColumn.getOrder(); this.sortOrderComboBox.setSortOrder(new SortOrder(sort)); - String sortFormula = dSColumn.getSortFormula(); - sortFormulaTextField.setText(sortFormula); + BaseFormula sortFormulaObject = dSColumn.getSortFormulaObject(); + sortFormulaTextField.setValue(sortFormulaObject); } public void update(CellElement cellElement) { @@ -263,15 +273,7 @@ public class DSColumnAdvancedPane extends BasicPane { dSColumn.setOrder(this.sortOrderComboBox.getSortOrder().getOrder()); //lance:sort formula - String sText = null; - if (!(sortFormulaTextField.getText() == null || sortFormulaTextField.getText().trim().equals("") || sortFormulaTextField.getText().trim().equals("$$$"))) { - sText = new String(sortFormulaTextField.getText()); - } - if (!(sText == null || sText.length() < 1)) { - dSColumn.setSortFormula(sText); - } else { - dSColumn.setSortFormula(null); - } + dSColumn.setSortFormulaObject(sortFormulaTextField.getValue()); } } @@ -367,9 +369,9 @@ public class DSColumnAdvancedPane extends BasicPane { int selectCountType = selectCount.getType(); this.selectCountComboBox.setSelectedIndex(selectCountType); if (selectCountType == TOP.getValue()) { - this.topFormulaPane.populate(selectCount.getFormulaCount()); + this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); } else if (selectCountType == BOTTOM.getValue()) { - this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); } else if (selectCountType == SPECIFY.getValue()) { this.serialTextField.setText(selectCount.getSerial()); } @@ -395,9 +397,9 @@ public class DSColumnAdvancedPane extends BasicPane { dSColumn.setSelectCount(selectCount); selectCount.setType(selectCountSelectIndex); if (selectCountSelectIndex == TOP.getValue()) { - selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + selectCount.setFormulaObject(this.topFormulaPane.getFormula()); } else if (selectCountSelectIndex == BOTTOM.getValue()) { - selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); } else if (selectCountSelectIndex == SPECIFY.getValue()) { selectCount.setSerial(this.serialTextField.getText()); } @@ -407,19 +409,19 @@ public class DSColumnAdvancedPane extends BasicPane { private static class JFormulaField extends JPanel { private CellElement cellElement; - private UITextField formulaTextField; - private String defaultValue; + private FormulaTextField formulaTextField; + private BaseFormula defaultFormula; public JFormulaField(String defaultValue) { - this.defaultValue = defaultValue; + this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); this.setLayout(FRGUIPaneFactory.createBoxFlowLayout()); UILabel bottomLabel = new UILabel("="); bottomLabel.setFont(new Font("Dialog", Font.BOLD, 12)); this.add(bottomLabel); - formulaTextField = new UITextField(24); + formulaTextField = new FormulaTextField(24); this.add(formulaTextField); - formulaTextField.setText(defaultValue); + formulaTextField.setValue(defaultFormula); UIButton bottomFrmulaButton = new UIButton("..."); this.add(bottomFrmulaButton); @@ -439,16 +441,25 @@ public class DSColumnAdvancedPane extends BasicPane { public String getFormulaText() { return this.formulaTextField.getText(); } + + public void populateFormula(BaseFormula baseFormula) { + + this.formulaTextField.setValue(baseFormula); + this.formulaTextField.setText(baseFormula.getPureContent()); + } + + public BaseFormula getFormula() { + + return this.formulaTextField.getValue(); + } private ActionListener formulaButtonActionListener = new ActionListener() { public void actionPerformed(ActionEvent evt) { - BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); - String text = formulaTextField.getText(); - if (text == null || text.length() <= 0) { - valueFormula.setContent(defaultValue); - } else { - valueFormula.setContent(text); + + BaseFormula valueFormula = formulaTextField.getValue(); + if (valueFormula == null) { + valueFormula = BaseFormula.createFormulaBuilder().build(); } final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); @@ -457,7 +468,7 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { + if (!(value instanceof DSColumn)) { return; } DSColumn dsColumn = (DSColumn) value; @@ -470,9 +481,9 @@ public class DSColumnAdvancedPane extends BasicPane { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { - formulaTextField.setText(defaultValue); + formulaTextField.setValue(defaultFormula); } else { - formulaTextField.setText(valueFormula.getContent().substring(1)); + formulaTextField.setValue(valueFormula); } } }).setVisible(true); @@ -503,12 +514,12 @@ public class DSColumnAdvancedPane extends BasicPane { DSColumn dSColumn = (DSColumn) value; //formula - String valueFormula = dSColumn.getResult(); + BaseFormula valueFormula = dSColumn.getResultObject(); if (valueFormula == null) { - valueFormula = "$$$"; + valueFormula = BaseFormula.createFormulaBuilder().build("$$$"); } formulaField.populateElement(cellElement); - formulaField.populate(valueFormula); + formulaField.populateFormula(valueFormula); } public void update(CellElement cellElement) { @@ -516,13 +527,13 @@ public class DSColumnAdvancedPane extends BasicPane { return; } Object value = cellElement.getValue(); - if (value == null || !(value instanceof DSColumn)) { + if (!(value instanceof DSColumn)) { return; } DSColumn dSColumn = (DSColumn) (cellElement.getValue()); //formula - dSColumn.setResult(this.formulaField.getFormulaText()); + dSColumn.setResultObject(this.formulaField.getFormula()); } } diff --git a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java index ea78f568f..11ae412ec 100644 --- a/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java +++ b/designer-realize/src/main/java/com/fr/design/parameter/ParameterDefinitePane.java @@ -17,6 +17,7 @@ import com.fr.design.designer.TargetComponent; import com.fr.design.event.TargetModifiedEvent; import com.fr.design.event.TargetModifiedListener; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.layout.FRGUIPaneFactory; @@ -30,6 +31,10 @@ import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; import com.fr.design.module.DesignModuleFactory; import com.fr.design.style.background.BackgroundPane; +import com.fr.form.main.parameter.FormParameterUI; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WLayout; import com.fr.log.FineLoggerFactory; import com.fr.main.parameter.ReportParameterAttr; import com.fr.main.parameter.TemplateParameterAttr; @@ -46,6 +51,7 @@ import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ItemEvent; @@ -212,12 +218,13 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus return parameterArray; } - public int getToolBarHeight(){ + public int getToolBarHeight() { return TOOLBARPANEDIMHEIGHT; } /** * 导出菜单项,用于图表设计器 + * * @return 菜单项 */ public ShortCut[] shortcut4ExportMenu() { @@ -248,6 +255,22 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus FineLoggerFactory.getLogger().error(e.getMessage(), e); } } + currentIndex = reportParameterAttr.getCurrentIndex(); + //因为以前的版本没有保存currentIndex,所以要计算currentIndex的值 + if (parameterUI != null && parameterUI instanceof FormParameterUI && currentIndex == 0) { + WLayout wLayout = ((FormParameterUI) parameterUI).getContainer(); + int widgetCount = wLayout.getWidgetCount(); + Rectangle endRec = null; + for (int i = 0; i < widgetCount; i++) { + Widget widget = wLayout.getWidget(i); + Rectangle tempRec = ((WAbsoluteLayout.BoundsWidget) widget).getBounds(); + if (endRec == null || tempRec.y > endRec.y) { + endRec = tempRec; + } + } + if (endRec != null) + currentIndex = (int) (Math.ceil(endRec.y / FormParaDesigner.V_COMPONENT_GAP)) * NUM_IN_A_LINE; + } paraDesignEditor.populate(parameterUI); @@ -376,8 +399,9 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus } //这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性 paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(), - (int)paraDesignEditor.getParaTarget().getDesignSize().getHeight())); + (int) paraDesignEditor.getParaTarget().getDesignSize().getHeight())); reportParameterAttr.setParameterUI(parameterUI); + reportParameterAttr.setCurrentIndex(currentIndex); return reportParameterAttr; } @@ -434,7 +458,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus return; } - paraDesignEditor.addingAllParameter2Editor(parameterArray, currentIndex); + currentIndex = paraDesignEditor.addingAllParameter2EditorWithReturnValue(parameterArray, currentIndex); parameterArray = null; refreshParameter(); @@ -489,7 +513,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus * @return 模板菜单 */ public MenuDef[] menus4Target() { - MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(),KeySetUtils.TEMPLATE.getMnemonic()); + MenuDef tplMenu = new MenuDef(KeySetUtils.TEMPLATE.getMenuKeySetName(), KeySetUtils.TEMPLATE.getMnemonic()); if (!DesignerMode.isAuthorityEditing()) { tplMenu.addShortCut(new NameSeparator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_WorkBook"))); tplMenu.addShortCut(new ReportParameterAction(workBook)); diff --git a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index fb80e8891..983fbb9da 100644 --- a/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java +++ b/designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -12,6 +12,7 @@ import com.fr.design.dscolumn.SelectedDataColumnPane; import com.fr.design.event.UIObserverListener; import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; +import com.fr.design.formula.FormulaTextField; import com.fr.design.formula.UIFormula; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -645,6 +646,7 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class ResultSetSortConfigPane extends JPanel { private static final String DEFAULT_VALUE = "="; + private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(); private JPanel contentPane; private UIButtonGroup sortTypePane; private JFormulaField formulaField; @@ -719,11 +721,11 @@ public class CellDSColumnEditor extends CellQuickEditor { centerPane.setPreferredSize(new Dimension(156, 20)); TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 2, VGAP); } - String sortFormula = dSColumn.getSortFormula(); - if (sortFormula != null && sortFormula.length() >= 1) { - this.formulaField.populate(sortFormula); + BaseFormula baseFormula = dSColumn.getSortFormulaObject(); + if (baseFormula == null) { + this.formulaField.populateFormula(DEFAULT_FORMULA); } else { - this.formulaField.populate(DEFAULT_VALUE); + this.formulaField.populateFormula(baseFormula); } } } @@ -740,7 +742,7 @@ public class CellDSColumnEditor extends CellQuickEditor { if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; dSColumn.setOrder(this.sortTypePane.getSelectedIndex()); - dSColumn.setSortFormula(this.formulaField.getFormulaText()); + dSColumn.setSortFormulaObject(this.formulaField.getFormula()); } } } @@ -774,6 +776,7 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class ResultSetFilterConfigPane extends JPanel { private static final String DEFAULT_VALUE = "="; + private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); private JPanel contentPane; private UIComboBox rsComboBox; @@ -918,8 +921,8 @@ public class CellDSColumnEditor extends CellQuickEditor { CardLayout setCardPaneLayout = (CardLayout) setCardPane.getLayout(); CardLayout tipCardPaneLayout = (CardLayout) tipCardPane.getLayout(); // 重置默认值 - this.topFormulaPane.populate(DEFAULT_VALUE); - this.bottomFormulaPane.populate(DEFAULT_VALUE); + this.topFormulaPane.populateFormula(DEFAULT_FORMULA); + this.bottomFormulaPane.populateFormula(DEFAULT_FORMULA); this.serialTextField.setText(StringUtils.EMPTY); if (selectCount != null) { @@ -927,7 +930,7 @@ public class CellDSColumnEditor extends CellQuickEditor { this.rsComboBox.setSelectedIndex(selectCountType); switch (FilterTypeEnum.getFilterByValue(selectCountType)) { case TOP: - this.topFormulaPane.populate(selectCount.getFormulaCount()); + this.topFormulaPane.populateFormula(selectCount.getFormulaObject()); //前N个 setCardPaneLayout.show(setCardPane, TOP.name()); tipCardPaneLayout.show(tipCardPane, TOP.name()); @@ -938,7 +941,7 @@ public class CellDSColumnEditor extends CellQuickEditor { TableLayoutHelper.modifyTableLayoutIndexVGap(contentPane, 4, 0); break; case BOTTOM: - this.bottomFormulaPane.populate(selectCount.getFormulaCount()); + this.bottomFormulaPane.populateFormula(selectCount.getFormulaObject()); //后N个 setCardPaneLayout.show(setCardPane, BOTTOM.name()); tipCardPaneLayout.show(tipCardPane, BOTTOM.name()); @@ -1019,9 +1022,9 @@ public class CellDSColumnEditor extends CellQuickEditor { dSColumn.setSelectCount(selectCount); //noinspection Duplicates if (selectedFilterIndex == TOP.getValue()) { - selectCount.setFormulaCount(this.topFormulaPane.getFormulaText()); + selectCount.setFormulaObject(this.topFormulaPane.getFormula()); } else if (selectedFilterIndex == BOTTOM.getValue()) { - selectCount.setFormulaCount(this.bottomFormulaPane.getFormulaText()); + selectCount.setFormulaObject(this.bottomFormulaPane.getFormula()); } else if (selectedFilterIndex == SPECIFY.getValue()) { selectCount.setSerial(this.serialTextField.getText()); } @@ -1060,14 +1063,15 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class JFormulaField extends JPanel { private CellElement cellElement; - private UITextField formulaTextField; - private String defaultValue; + private FormulaTextField formulaTextField; + private BaseFormula defaultFormula; public JFormulaField(String defaultValue) { - this.defaultValue = defaultValue; - formulaTextField = new UITextField(); - formulaTextField.setText(defaultValue); + this.defaultFormula = BaseFormula.createFormulaBuilder().build(defaultValue); + formulaTextField = new FormulaTextField(); + formulaTextField.setValue(defaultFormula); + JPanel textFieldPane = new JPanel(new BorderLayout()); textFieldPane.add(formulaTextField, BorderLayout.CENTER); textFieldPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); @@ -1094,6 +1098,16 @@ public class CellDSColumnEditor extends CellQuickEditor { public String getFormulaText() { return this.formulaTextField.getText().trim(); } + + public void populateFormula(BaseFormula baseFormula) { + + this.formulaTextField.setValue(baseFormula); + } + + public BaseFormula getFormula() { + + return this.formulaTextField.getValue(); + } /** * 添加事件监听器 @@ -1114,16 +1128,14 @@ public class CellDSColumnEditor extends CellQuickEditor { private ActionListener formulaButtonActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { - BaseFormula valueFormula = BaseFormula.createFormulaBuilder().build(); - String text = formulaTextField.getText(); - if (text == null || text.length() <= 0) { - valueFormula.setContent(defaultValue); - } else { - valueFormula.setContent(text); + + BaseFormula valueFormula = formulaTextField.getValue(); + if (valueFormula == null) { + valueFormula = BaseFormula.createFormulaBuilder().build(); } final UIFormula formulaPane = FormulaFactory.createFormulaPaneWhenReserveFormula(); if (cellElement != null) { - Object value = cellElement.getValue(); + final Object value = cellElement.getValue(); if (value instanceof DSColumn) { DSColumn dsColumn = (DSColumn) value; String[] displayNames = DesignTableDataManager.getSelectedColumnNames(DesignTableDataManager.getEditingTableDataSource(), dsColumn.getDSName()); @@ -1133,9 +1145,9 @@ public class CellDSColumnEditor extends CellQuickEditor { public void doOk() { BaseFormula valueFormula = formulaPane.update(); if (valueFormula.getContent().length() <= 1) { - formulaTextField.setText(defaultValue); + formulaTextField.setValue(defaultFormula); } else { - formulaTextField.setText(valueFormula.getContent()); + formulaTextField.setValue(valueFormula); } } }).setVisible(true); @@ -1152,6 +1164,7 @@ public class CellDSColumnEditor extends CellQuickEditor { */ public class CustomValuePane extends JPanel { private static final String DEFAULT_VALUE = "=$$$"; + private final BaseFormula DEFAULT_FORMULA = BaseFormula.createFormulaBuilder().build(DEFAULT_VALUE); private JFormulaField formulaField; @@ -1171,11 +1184,11 @@ public class CellDSColumnEditor extends CellQuickEditor { if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) value; //formula - String valueFormula = dSColumn.getResult(); + BaseFormula valueFormula = dSColumn.getResultObject(); if (valueFormula != null) { - formulaField.populate(valueFormula); + formulaField.populateFormula(valueFormula); } else { - formulaField.populate(DEFAULT_VALUE); + formulaField.populateFormula(DEFAULT_FORMULA); } formulaField.populateElement(cellElement); @@ -1188,8 +1201,7 @@ public class CellDSColumnEditor extends CellQuickEditor { Object value = cellElement.getValue(); if (value instanceof DSColumn) { DSColumn dSColumn = (DSColumn) (cellElement.getValue()); - dSColumn.setResult(StringUtils.isEmpty(this.formulaField.getFormulaText()) ? - null : this.formulaField.getFormulaText()); + dSColumn.setResultObject(this.formulaField.getFormula()); } } } diff --git a/pom.xml b/pom.xml index 407f1fd17..711751c9f 100644 --- a/pom.xml +++ b/pom.xml @@ -28,8 +28,8 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 1.8 + 1.8