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();
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);
// 更新字段格式和汇总方式

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.layout.TableLayout;
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 javax.swing.Icon;
@ -28,19 +30,20 @@ public class VanChartFieldButton extends JPanel {
private final String fieldName;
private final String fieldId;
private final AttrTooltipFormat tooltipFormat;
private final boolean showDataFunction;
private UIToggleButton fieldButton;
private UIButton addButton;
private Format format;
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.fieldId = fieldId;
this.tooltipFormat = format;
this.showDataFunction = showDataFunction;
this.showDataFunction = showSummary;
this.fieldId = format == null ? StringUtils.EMPTY : format.getFormatJSONKey();
initComponents(fieldName, listener);
@ -52,12 +55,20 @@ public class VanChartFieldButton extends JPanel {
return fieldName;
}
public boolean isEnable() {
return this.tooltipFormat.isEnable();
}
public void setEnable(boolean enable) {
this.tooltipFormat.setEnable(enable);
}
public Format getFormat() {
return format;
return tooltipFormat.getFormat();
}
public void setFormat(Format format) {
this.format = format;
this.tooltipFormat.setFormat(format);
}
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.plugin.chart.base.AttrTooltipContent;
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.AttrTooltipSeriesFormat;
import com.fr.plugin.chart.base.format.AttrTooltipValueFormat;
@ -49,6 +50,8 @@ public class VanChartFieldListPane extends JPanel {
this.richEditorPane = richEditorPane;
initFieldListListener();
initDefaultFieldButton();
registerAttrListener();
this.setLayout(new BorderLayout());
@ -58,58 +61,37 @@ public class VanChartFieldListPane extends JPanel {
}
private JPanel createDefaultFieldPane() {
JPanel defaultField = new JPanel();
defaultField.setLayout(new GridLayout(0, 1, 1, 0));
createDefaultButtonGroup(defaultField);
List<VanChartFieldButton> defaultFieldButtonList = getDefaultFieldButtonList();
defaultField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldButtonList.size() * FIELD_ADD_H));
defaultField.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0));
return defaultField;
}
JPanel fieldPane = new JPanel();
protected void createDefaultButtonGroup(JPanel field) {
categoryNameButton = createCategoryFieldButton();
seriesNameButton = createSeriesFieldButton();
valueButton = createValueFieldButton();
percentButton = createPercentFieldButton();
fieldPane.setLayout(new GridLayout(0, 1, 1, 0));
field.add(categoryNameButton);
field.add(seriesNameButton);
field.add(valueButton);
field.add(percentButton);
}
addDefaultFieldButton(fieldPane);
// 不同图表的name和id不一样
protected VanChartFieldButton createCategoryFieldButton() {
String name = Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name");
String id = new AttrTooltipCategoryFormat().getFormatJSONKey();
fieldPane.setPreferredSize(new Dimension(FIELD_ADD_W, getDefaultFieldButtonList().size() * FIELD_ADD_H));
fieldPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0));
return new VanChartFieldButton(name, id, false, fieldListener);
return fieldPane;
}
protected VanChartFieldButton createSeriesFieldButton() {
String name = Toolkit.i18nText("Fine-Design_Chart_Series_Name");
String id = new AttrTooltipSeriesFormat().getFormatJSONKey();
protected void initDefaultFieldButton() {
categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"),
new AttrTooltipCategoryFormat(), false, fieldListener);
return new VanChartFieldButton(name, id, false, fieldListener);
}
seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"),
new AttrTooltipSeriesFormat(), false, fieldListener);
protected VanChartFieldButton createValueFieldButton() {
String name = Toolkit.i18nText("Fine-Design_Chart_Use_Value");
String id = new AttrTooltipValueFormat().getFormatJSONKey();
valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"),
new AttrTooltipValueFormat(), false, fieldListener);
return new VanChartFieldButton(name, id, false, fieldListener);
percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"),
new AttrTooltipPercentFormat(), 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);
protected void addDefaultFieldButton(JPanel fieldPane) {
fieldPane.add(categoryNameButton);
fieldPane.add(seriesNameButton);
fieldPane.add(valueButton);
fieldPane.add(percentButton);
}
private JPanel createTableFieldPane() {
@ -122,7 +104,7 @@ public class VanChartFieldListPane extends JPanel {
tableField.setLayout(new GridLayout(0, 1, 1, 0));
for (String name : tableFieldNameList) {
VanChartFieldButton fieldButton = new VanChartFieldButton(name, name, true, fieldListener);
VanChartFieldButton fieldButton = new VanChartFieldButton(name, getTableTooltipFormat(name), true, fieldListener);
tableField.add(fieldButton);
tableFieldButtonList.add(fieldButton);
@ -133,6 +115,11 @@ public class VanChartFieldListPane extends JPanel {
return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField);
}
// 生成新增字段对应的format
private AttrTooltipFormat getTableTooltipFormat(String fieldName) {
return new AttrTooltipCategoryFormat();
}
protected List<VanChartFieldButton> getDefaultFieldButtonList() {
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) {
populateDefaultField(tooltipContent);
populateTableField(tooltipContent);
@ -265,10 +248,19 @@ public class VanChartFieldListPane extends JPanel {
}
public void populateDefaultField(AttrTooltipContent tooltipContent) {
categoryNameButton.setFormat(tooltipContent.getRichTextCategoryFormat().getFormat());
seriesNameButton.setFormat(tooltipContent.getRichTextSeriesFormat().getFormat());
valueButton.setFormat(tooltipContent.getRichTextValueFormat().getFormat());
percentButton.setFormat(tooltipContent.getRichTextPercentFormat().getFormat());
populateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat());
populateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat());
populateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat());
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) {
@ -281,13 +273,22 @@ public class VanChartFieldListPane extends JPanel {
}
public void updateDefaultField(AttrTooltipContent tooltipContent) {
tooltipContent.getRichTextCategoryFormat().setFormat(categoryNameButton.getFormat());
tooltipContent.getRichTextSeriesFormat().setFormat(seriesNameButton.getFormat());
tooltipContent.getRichTextValueFormat().setFormat(valueButton.getFormat());
tooltipContent.getRichTextPercentFormat().setFormat(percentButton.getFormat());
updateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat());
updateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat());
updateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat());
updateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat());
}
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.plugin.chart.base.AttrTooltipContent;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.style.VanChartStylePane;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
@ -26,27 +25,14 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
private VanChartFieldListPane fieldListPane;
private VanChartFieldAttrPane fieldAttrPane;
private VanChartStylePane parent;
public VanChartRichTextPane(List<String> tableFieldNames, ModernUIPane<VanChartRichEditorModel> richEditor) {
private List<String> tableFieldsFormat;
private ModernUIPane<VanChartRichEditorModel> richEditor;
public VanChartRichTextPane(VanChartStylePane parent, List<String> tableFieldsFormat, ModernUIPane<VanChartRichEditorModel> richEditor) {
this.parent = parent;
this.tableFieldsFormat = tableFieldsFormat;
this.richEditor = richEditor;
initFieldContent();
fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = new VanChartFieldListPane(tableFieldNames, fieldAttrPane, richEditor);
this.setLayout(new BorderLayout());
this.add(createFieldContentPane(), BorderLayout.CENTER);
this.add(createRichEditorPane(), BorderLayout.SOUTH);
}
private void initFieldContent() {
fieldAttrPane = new VanChartFieldAttrPane();
fieldListPane = new VanChartFieldListPane(tableFieldsFormat, fieldAttrPane, richEditor);
this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH);
}
private JPanel createFieldContentPane() {
@ -73,12 +59,12 @@ public class VanChartRichTextPane extends BasicBeanPane<AttrTooltipContent> {
return fieldPane;
}
private JPanel createRichEditorPane() {
private JPanel createRichEditorPane(JPanel richEditor) {
JPanel richEditorPane = new JPanel();
richEditorPane.setLayout(new BorderLayout());
richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H));
richEditorPane.add(this.richEditor, BorderLayout.CENTER);
richEditorPane.add(richEditor, BorderLayout.CENTER);
return richEditorPane;
}

Loading…
Cancel
Save