Browse Source

简化本地变量

feature/big-screen
Qinghui.Liu 5 years ago
parent
commit
c12aa0e57b
  1. 41
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java

41
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/style/ChartTextAttrPaneWithAuto.java

@ -12,9 +12,9 @@ import com.fr.general.GeneralUtils;
public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane { public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto"); private static final String AUTO = Toolkit.i18nText("Fine-Design_Basic_ChartF_Auto");
private boolean isFontSizeAuto = false; private FontAutoType type;
private boolean isColorAuto = false;
public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2]; public static String[] FONT_SIZES_WITH_AUTO = new String[FONT_END - FONT_START + 2];
static { static {
FONT_SIZES_WITH_AUTO[0] = AUTO; FONT_SIZES_WITH_AUTO[0] = AUTO;
@ -24,42 +24,29 @@ public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
} }
public ChartTextAttrPaneWithAuto(FontAutoType type) { public ChartTextAttrPaneWithAuto(FontAutoType type) {
initAutoType(type); this.type = type;
initState(); initState();
initComponents(); initComponents();
} }
private void initAutoType(FontAutoType type) { private boolean isFontSizeAuto() {
switch (type) { return type == FontAutoType.SIZE || type == FontAutoType.SIZE_AND_COLOR;
case NONE: }
this.isFontSizeAuto = false;
this.isColorAuto = false; private boolean isFontColorAuto() {
break; return type == FontAutoType.COLOR || type == FontAutoType.SIZE_AND_COLOR;
case SIZE:
this.isFontSizeAuto = true;
this.isColorAuto = false;
break;
case COLOR:
this.isFontSizeAuto = false;
this.isColorAuto = true;
break;
case SIZE_AND_COLOR:
this.isFontSizeAuto = true;
this.isColorAuto = true;
break;
}
} }
protected void initFontColorState() { protected void initFontColorState() {
setFontColor(isColorAuto ? new UIColorButtonWithAuto() : new UIColorButton()); setFontColor(isFontColorAuto() ? new UIColorButtonWithAuto() : new UIColorButton());
} }
protected Object[] getFontSizeComboBoxModel() { protected Object[] getFontSizeComboBoxModel() {
return isFontSizeAuto ? FONT_SIZES_WITH_AUTO : FONT_SIZES; return isFontSizeAuto() ? FONT_SIZES_WITH_AUTO : FONT_SIZES;
} }
protected float updateFontSize() { protected float updateFontSize() {
if (isFontSizeAuto && ComparatorUtils.equals(getFontSizeComboBox().getSelectedItem(), AUTO)) { if (isFontSizeAuto() && ComparatorUtils.equals(getFontSizeComboBox().getSelectedItem(), AUTO)) {
return ChartConstants.AUTO_FONT_SIZE; return ChartConstants.AUTO_FONT_SIZE;
} }
@ -67,7 +54,7 @@ public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
} }
protected void populateFontSize(FRFont frFont) { protected void populateFontSize(FRFont frFont) {
if (getFontSizeComboBox() != null && isFontSizeAuto) { if (getFontSizeComboBox() != null && isFontSizeAuto()) {
if (frFont.getSize() == ChartConstants.AUTO_FONT_SIZE) { if (frFont.getSize() == ChartConstants.AUTO_FONT_SIZE) {
getFontSizeComboBox().setSelectedItem(AUTO); getFontSizeComboBox().setSelectedItem(AUTO);
} else { } else {
@ -75,7 +62,7 @@ public class ChartTextAttrPaneWithAuto extends ChartTextAttrPane {
} }
} }
if (getFontSizeComboBox() != null && !isFontSizeAuto) { if (getFontSizeComboBox() != null && !isFontSizeAuto()) {
getFontSizeComboBox().setSelectedItem(frFont.getSize()); getFontSizeComboBox().setSelectedItem(frFont.getSize());
} }
} }

Loading…
Cancel
Save