Browse Source

消除魔术数

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
79696bbb3d
  1. 47
      designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java

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

@ -51,6 +51,15 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private static final long serialVersionUID = 8825929000117843641L; private static final long serialVersionUID = 8825929000117843641L;
// 字符样式button
private static final int TEXT_ATTR_AUTO_INDEX = 0;
private static final int TEXT_ATTR_CUSTOM_INDEX = 1;
// 标签内容button
private static final int COMMON_INDEX = 0;
private static final int RICH_EDITOR_INDEX = 1;
private static final int CUSTOM_INDEX_WITH_RICH_EDITOR = 2;
private static final int CUSTOM_INDEX_WITHOUT_RICH_EDITOR = 1;
private UIButtonGroup<Integer> content; private UIButtonGroup<Integer> content;
private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane;
@ -232,9 +241,9 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void initCenterPaneWithRichEditor() { private void initCenterPaneWithRichEditor() {
centerPanel = new JPanel(new CardLayout()) { centerPanel = new JPanel(new CardLayout()) {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if (content.getSelectedIndex() == 0) { if (content.getSelectedIndex() == COMMON_INDEX) {
return commonPanel.getPreferredSize(); return commonPanel.getPreferredSize();
} else if (content.getSelectedIndex() == 1) { } else if (content.getSelectedIndex() == RICH_EDITOR_INDEX) {
return editorPanel.getPreferredSize(); return editorPanel.getPreferredSize();
} else { } else {
return htmlPanel.getPreferredSize(); return htmlPanel.getPreferredSize();
@ -250,7 +259,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void initCenterPaneWithoutRichEditor() { private void initCenterPaneWithoutRichEditor() {
centerPanel = new JPanel(new CardLayout()) { centerPanel = new JPanel(new CardLayout()) {
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
if (content.getSelectedIndex() == 0) { if (content.getSelectedIndex() == COMMON_INDEX) {
return commonPanel.getPreferredSize(); return commonPanel.getPreferredSize();
} else { } else {
return htmlPanel.getPreferredSize(); return htmlPanel.getPreferredSize();
@ -359,7 +368,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void checkStylePane() { private void checkStylePane() {
if (hasTextStylePane()) { if (hasTextStylePane()) {
stylePanel.setVisible(true); stylePanel.setVisible(true);
textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); textAttrPane.setVisible(styleButton.getSelectedIndex() == TEXT_ATTR_CUSTOM_INDEX);
} else { } else {
stylePanel.setVisible(false); stylePanel.setVisible(false);
} }
@ -508,22 +517,22 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void checkCardPaneWithRichEditor() { private void checkCardPaneWithRichEditor() {
CardLayout cardLayout = (CardLayout) centerPanel.getLayout(); CardLayout cardLayout = (CardLayout) centerPanel.getLayout();
if (content.getSelectedIndex() == 2) { if (content.getSelectedIndex() == CUSTOM_INDEX_WITH_RICH_EDITOR) {
cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Custom")); cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Custom"));
checkCustomPane(); checkCustomPane();
} else if (content.getSelectedIndex() == 1) { } else if (content.getSelectedIndex() == RICH_EDITOR_INDEX) {
cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Rich_Text")); cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Rich_Text"));
} else { } else {
cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Common"));
} }
stylePanel.setVisible(hasTextStylePane() && content.getSelectedIndex() != 1); stylePanel.setVisible(hasTextStylePane() && content.getSelectedIndex() != RICH_EDITOR_INDEX);
} }
private void checkCardPaneWithoutRichEditor() { private void checkCardPaneWithoutRichEditor() {
CardLayout cardLayout = (CardLayout) centerPanel.getLayout(); CardLayout cardLayout = (CardLayout) centerPanel.getLayout();
if (content.getSelectedIndex() == 1) { if (content.getSelectedIndex() == CUSTOM_INDEX_WITHOUT_RICH_EDITOR) {
cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Custom")); cardLayout.show(centerPanel, Toolkit.i18nText("Fine-Design_Chart_Custom"));
checkCustomPane(); checkCustomPane();
} else { } else {
@ -587,9 +596,9 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
} }
if (hasTextStylePane()) { if (hasTextStylePane()) {
if (attrTooltipContent.isCustom()) { if (attrTooltipContent.isCustom()) {
styleButton.setSelectedIndex(1); styleButton.setSelectedIndex(TEXT_ATTR_CUSTOM_INDEX);
} else { } else {
styleButton.setSelectedIndex(0); styleButton.setSelectedIndex(TEXT_ATTR_AUTO_INDEX);
} }
this.textAttrPane.populate(attrTooltipContent.getTextAttr()); this.textAttrPane.populate(attrTooltipContent.getTextAttr());
} }
@ -606,20 +615,20 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void populateTypeButton(AttrTooltipContent attrTooltipContent) { private void populateTypeButton(AttrTooltipContent attrTooltipContent) {
if (supportRichEditor()) { if (supportRichEditor()) {
if (attrTooltipContent.isCommon()) { if (attrTooltipContent.isCommon()) {
content.setSelectedIndex(0); content.setSelectedIndex(COMMON_INDEX);
} else if (attrTooltipContent.isRichText()) { } else if (attrTooltipContent.isRichText()) {
content.setSelectedIndex(1); content.setSelectedIndex(RICH_EDITOR_INDEX);
} else { } else {
content.setSelectedIndex(2); content.setSelectedIndex(CUSTOM_INDEX_WITH_RICH_EDITOR);
} }
return; return;
} }
if (attrTooltipContent.isCommon()) { if (attrTooltipContent.isCommon()) {
content.setSelectedIndex(0); content.setSelectedIndex(COMMON_INDEX);
} else { } else {
content.setSelectedIndex(1); content.setSelectedIndex(CUSTOM_INDEX_WITHOUT_RICH_EDITOR);
} }
} }
@ -706,7 +715,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
updateTooltipRichText(attrTooltipContent); updateTooltipRichText(attrTooltipContent);
} }
if (hasTextStylePane()) { if (hasTextStylePane()) {
attrTooltipContent.setCustom(styleButton.getSelectedIndex() == 1); attrTooltipContent.setCustom(styleButton.getSelectedIndex() == TEXT_ATTR_CUSTOM_INDEX);
attrTooltipContent.setTextAttr(this.textAttrPane.update()); attrTooltipContent.setTextAttr(this.textAttrPane.update());
} }
@ -719,13 +728,13 @@ public class VanChartTooltipContentPane extends BasicBeanPane<AttrTooltipContent
private void updateLabelType(AttrTooltipContent attrTooltipContent) { private void updateLabelType(AttrTooltipContent attrTooltipContent) {
if (supportRichEditor()) { if (supportRichEditor()) {
attrTooltipContent.setCommon(content.getSelectedIndex() == 0); attrTooltipContent.setCommon(content.getSelectedIndex() == COMMON_INDEX);
attrTooltipContent.setRichText(content.getSelectedIndex() == 1); attrTooltipContent.setRichText(content.getSelectedIndex() == RICH_EDITOR_INDEX);
return; return;
} }
attrTooltipContent.setCommon(content.getSelectedIndex() == 0); attrTooltipContent.setCommon(content.getSelectedIndex() == COMMON_INDEX);
attrTooltipContent.setRichText(false); attrTooltipContent.setRichText(false);
} }

Loading…
Cancel
Save