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

Loading…
Cancel
Save