Browse Source

完善界面

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
6ff17bf1a7
  1. 2
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java
  2. 23
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java
  3. 109
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java
  4. 26
      designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

2
designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java

@ -439,7 +439,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr(); AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr();
ModernUIPane<VanChartRichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); ModernUIPane<VanChartRichEditorModel> richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText);
VanChartRichTextPane richTextPane = new VanChartRichTextPane(parent, getTableFieldNames(), richEditorPane); VanChartRichTextPane richTextPane = new VanChartRichTextPane(getTableFieldNames(), richEditorPane);
BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane);
// 更新字段格式和汇总方式 // 更新字段格式和汇总方式

23
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldButton.java

@ -6,6 +6,8 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.Icon; import javax.swing.Icon;
@ -28,19 +30,20 @@ public class VanChartFieldButton extends JPanel {
private final String fieldName; private final String fieldName;
private final String fieldId; private final String fieldId;
private final AttrTooltipFormat tooltipFormat;
private final boolean showDataFunction; private final boolean showDataFunction;
private UIToggleButton fieldButton; private UIToggleButton fieldButton;
private UIButton addButton; private UIButton addButton;
private Format format;
private DataFunction dataFunction; private DataFunction dataFunction;
public VanChartFieldButton(String fieldName, String fieldId, boolean showSummary, VanChartFieldListener listener) { public VanChartFieldButton(String fieldName, AttrTooltipFormat format, boolean showDataFunction, VanChartFieldListener listener) {
this.fieldName = fieldName; this.fieldName = fieldName;
this.fieldId = fieldId; this.tooltipFormat = format;
this.showDataFunction = showDataFunction;
this.showDataFunction = showSummary; this.fieldId = format == null ? StringUtils.EMPTY : format.getFormatJSONKey();
initComponents(fieldName, listener); initComponents(fieldName, listener);
@ -52,12 +55,20 @@ public class VanChartFieldButton extends JPanel {
return fieldName; return fieldName;
} }
public boolean isEnable() {
return this.tooltipFormat.isEnable();
}
public void setEnable(boolean enable) {
this.tooltipFormat.setEnable(enable);
}
public Format getFormat() { public Format getFormat() {
return format; return tooltipFormat.getFormat();
} }
public void setFormat(Format format) { public void setFormat(Format format) {
this.format = format; this.tooltipFormat.setFormat(format);
} }
public DataFunction getDataFunction() { public DataFunction getDataFunction() {

109
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java

@ -7,6 +7,7 @@ import com.fr.design.ui.ModernUIPane;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat;
import com.fr.plugin.chart.base.format.AttrTooltipFormat;
import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat;
import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
@ -49,6 +50,8 @@ public class VanChartFieldListPane extends JPanel {
this.richEditorPane = richEditorPane; this.richEditorPane = richEditorPane;
initFieldListListener(); initFieldListListener();
initDefaultFieldButton();
registerAttrListener(); registerAttrListener();
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
@ -58,58 +61,37 @@ public class VanChartFieldListPane extends JPanel {
} }
private JPanel createDefaultFieldPane() { private JPanel createDefaultFieldPane() {
JPanel defaultField = new JPanel(); JPanel fieldPane = new JPanel();
defaultField.setLayout(new GridLayout(0, 1, 1, 0)); fieldPane.setLayout(new GridLayout(0, 1, 1, 0));
createDefaultButtonGroup(defaultField);
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList(); addDefaultFieldButton(fieldPane);
defaultField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldButtonList.size() * FIELD_ADD_H)); fieldPane.setPreferredSize(new Dimension(FIELD_ADD_W, getDefaultFieldButtonList().size() * FIELD_ADD_H));
defaultField.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); fieldPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0));
return defaultField; return fieldPane;
} }
protected void createDefaultButtonGroup(JPanel field) { protected void initDefaultFieldButton() {
categoryNameButton = createCategoryFieldButton(); categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"),
seriesNameButton = createSeriesFieldButton(); new AttrTooltipCategoryFormat(), false, fieldListener);
valueButton = createValueFieldButton();
percentButton = createPercentFieldButton();
field.add(categoryNameButton); seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"),
field.add(seriesNameButton); new AttrTooltipSeriesFormat(), false, fieldListener);
field.add(valueButton);
field.add(percentButton);
}
// 不同图表的name和id不一样 valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"),
protected VanChartFieldButton createCategoryFieldButton() { new AttrTooltipValueFormat(), false, fieldListener);
String name = Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name");
String id = new AttrTooltipCategoryFormat().getFormatJSONKey();
return new VanChartFieldButton(name, id, false, fieldListener); percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"),
new AttrTooltipPercentFormat(), false, fieldListener);
} }
protected VanChartFieldButton createSeriesFieldButton() { protected void addDefaultFieldButton(JPanel fieldPane) {
String name = Toolkit.i18nText("Fine-Design_Chart_Series_Name"); fieldPane.add(categoryNameButton);
String id = new AttrTooltipSeriesFormat().getFormatJSONKey(); fieldPane.add(seriesNameButton);
fieldPane.add(valueButton);
return new VanChartFieldButton(name, id, false, fieldListener); fieldPane.add(percentButton);
}
protected VanChartFieldButton createValueFieldButton() {
String name = Toolkit.i18nText("Fine-Design_Chart_Use_Value");
String id = new AttrTooltipValueFormat().getFormatJSONKey();
return new VanChartFieldButton(name, id, false, fieldListener);
}
protected VanChartFieldButton createPercentFieldButton() {
String name = Toolkit.i18nText("Fine-Design_Chart_Use_Percent");
String id = new AttrTooltipPercentFormat().getFormatJSONKey();
return new VanChartFieldButton(name, id, false, fieldListener);
} }
private JPanel createTableFieldPane() { private JPanel createTableFieldPane() {
@ -122,7 +104,7 @@ public class VanChartFieldListPane extends JPanel {
tableField.setLayout(new GridLayout(0, 1, 1, 0)); tableField.setLayout(new GridLayout(0, 1, 1, 0));
for (String name : tableFieldNameList) { for (String name : tableFieldNameList) {
VanChartFieldButton fieldButton = new VanChartFieldButton(name, name, true, fieldListener); VanChartFieldButton fieldButton = new VanChartFieldButton(name, getTableTooltipFormat(name), true, fieldListener);
tableField.add(fieldButton); tableField.add(fieldButton);
tableFieldButtonList.add(fieldButton); tableFieldButtonList.add(fieldButton);
@ -133,6 +115,11 @@ public class VanChartFieldListPane extends JPanel {
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField);
} }
// 生成新增字段对应的format
private AttrTooltipFormat getTableTooltipFormat(String fieldName) {
return new AttrTooltipCategoryFormat();
}
protected List<VanChartFieldButton> getDefaultFieldButtonList() { protected List<VanChartFieldButton> getDefaultFieldButtonList() {
List<VanChartFieldButton> defaultFieldButtonList = new ArrayList<>(); List<VanChartFieldButton> defaultFieldButtonList = new ArrayList<>();
@ -252,10 +239,6 @@ public class VanChartFieldListPane extends JPanel {
} }
} }
private String getFieldRichText(String fieldName, String fieldId) {
return "<p><span>" + fieldName + "</span></p>";
}
public void populate(AttrTooltipContent tooltipContent) { public void populate(AttrTooltipContent tooltipContent) {
populateDefaultField(tooltipContent); populateDefaultField(tooltipContent);
populateTableField(tooltipContent); populateTableField(tooltipContent);
@ -265,10 +248,19 @@ public class VanChartFieldListPane extends JPanel {
} }
public void populateDefaultField(AttrTooltipContent tooltipContent) { public void populateDefaultField(AttrTooltipContent tooltipContent) {
categoryNameButton.setFormat(tooltipContent.getRichTextCategoryFormat().getFormat()); populateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat());
seriesNameButton.setFormat(tooltipContent.getRichTextSeriesFormat().getFormat()); populateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat());
valueButton.setFormat(tooltipContent.getRichTextValueFormat().getFormat()); populateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat());
percentButton.setFormat(tooltipContent.getRichTextPercentFormat().getFormat()); populateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat());
}
public void populateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) {
if (button == null || format == null) {
return;
}
button.setEnable(format.isEnable());
button.setFormat(format.getFormat());
} }
public void populateTableField(AttrTooltipContent tooltipContent) { public void populateTableField(AttrTooltipContent tooltipContent) {
@ -281,13 +273,22 @@ public class VanChartFieldListPane extends JPanel {
} }
public void updateDefaultField(AttrTooltipContent tooltipContent) { public void updateDefaultField(AttrTooltipContent tooltipContent) {
tooltipContent.getRichTextCategoryFormat().setFormat(categoryNameButton.getFormat()); updateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat());
tooltipContent.getRichTextSeriesFormat().setFormat(seriesNameButton.getFormat()); updateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat());
tooltipContent.getRichTextValueFormat().setFormat(valueButton.getFormat()); updateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat());
tooltipContent.getRichTextPercentFormat().setFormat(percentButton.getFormat()); updateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat());
} }
public void updateTableField(AttrTooltipContent tooltipContent) { public void updateTableField(AttrTooltipContent tooltipContent) {
} }
public void updateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) {
if (button == null || format == null) {
return;
}
format.setEnable(button.isEnable());
format.setFormat(button.getFormat());
}
} }

26
designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java

@ -5,7 +5,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.ui.ModernUIPane; import com.fr.design.ui.ModernUIPane;
import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipContent;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -26,27 +25,14 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
private VanChartFieldListPane fieldListPane; private VanChartFieldListPane fieldListPane;
private VanChartFieldAttrPane fieldAttrPane; private VanChartFieldAttrPane fieldAttrPane;
private VanChartStylePane parent; public VanChartRichTextPane(List<String> tableFieldNames, ModernUIPane<VanChartRichEditorModel> richEditor) {
private List<String> tableFieldsFormat; fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = new VanChartFieldListPane(tableFieldNames, fieldAttrPane, richEditor);
private ModernUIPane<VanChartRichEditorModel> richEditor;
public VanChartRichTextPane(VanChartStylePane parent, List<String> tableFieldsFormat, ModernUIPane<VanChartRichEditorModel> richEditor) {
this.parent = parent;
this.tableFieldsFormat = tableFieldsFormat;
this.richEditor = richEditor;
initFieldContent();
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(createFieldContentPane(), BorderLayout.CENTER); this.add(createFieldContentPane(), BorderLayout.CENTER);
this.add(createRichEditorPane(), BorderLayout.SOUTH); this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH);
}
private void initFieldContent() {
fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = new VanChartFieldListPane(tableFieldsFormat, fieldAttrPane, richEditor);
} }
private JPanel createFieldContentPane() { private JPanel createFieldContentPane() {
@ -73,12 +59,12 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
return fieldPane; return fieldPane;
} }
private JPanel createRichEditorPane() { private JPanel createRichEditorPane(JPanel richEditor) {
JPanel richEditorPane = new JPanel(); JPanel richEditorPane = new JPanel();
richEditorPane.setLayout(new BorderLayout()); richEditorPane.setLayout(new BorderLayout());
richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H));
richEditorPane.add(this.richEditor, BorderLayout.CENTER); richEditorPane.add(richEditor, BorderLayout.CENTER);
return richEditorPane; return richEditorPane;
} }

Loading…
Cancel
Save