1 30 31 package com.jgoodies.looks; 32 33 51 public final class FontSizeHints { 52 53 public static final FontSizeHints LARGE = new FontSizeHints(12, 12, 14, 14); 54 public static final FontSizeHints SYSTEM = new FontSizeHints(11, 11, 14, 14); 55 public static final FontSizeHints MIXED2 = new FontSizeHints(11, 11, 14, 13); 56 public static final FontSizeHints MIXED = new FontSizeHints(11, 11, 14, 12); 57 public static final FontSizeHints SMALL = new FontSizeHints(11, 11, 12, 12); 58 public static final FontSizeHints FIXED = new FontSizeHints(12, 12, 12, 12); 59 60 public static final FontSizeHints DEFAULT = SYSTEM; 61 62 63 private final int loResMenuFontSize; 64 private final int loResControlFontSize; 65 private final int hiResMenuFontSize; 66 private final int hiResControlFontSize; 67 68 69 78 public FontSizeHints(int loResMenuFontSize, int loResControlFontSize, 79 int hiResMenuFontSize, int hiResControlFontSize) { 80 this.loResMenuFontSize = loResMenuFontSize; 81 this.loResControlFontSize = loResControlFontSize; 82 this.hiResMenuFontSize = hiResMenuFontSize; 83 this.hiResControlFontSize = hiResControlFontSize; 84 } 85 86 87 92 public int loResMenuFontSize() { return loResMenuFontSize; } 93 94 95 100 public int loResControlFontSize() { return loResControlFontSize; } 101 102 103 108 public int hiResMenuFontSize() { return hiResMenuFontSize; } 109 110 111 116 public int hiResControlFontSize() { return hiResControlFontSize; } 117 118 119 124 public int menuFontSize() { 125 return LookUtils.IS_LOW_RESOLUTION ? loResMenuFontSize : hiResMenuFontSize(); 126 } 127 128 129 134 public int controlFontSize() { 135 return LookUtils.IS_LOW_RESOLUTION ? loResControlFontSize : hiResControlFontSize(); 136 } 137 138 139 146 public float menuFontSizeDelta() { 147 return menuFontSize() - SYSTEM.menuFontSize(); 148 } 149 150 151 158 public float controlFontSizeDelta() { 159 return controlFontSize() - SYSTEM.controlFontSize(); 160 } 161 162 163 164 170 public static FontSizeHints valueOf(String name) { 171 if (name.equalsIgnoreCase("LARGE")) 172 return LARGE; 173 else if (name.equalsIgnoreCase("SYSTEM")) 174 return SYSTEM; 175 else if (name.equalsIgnoreCase("MIXED")) 176 return MIXED; 177 else if (name.equalsIgnoreCase("SMALL")) 178 return SMALL; 179 else if (name.equalsIgnoreCase("FIXED")) 180 return FIXED; 181 else 182 throw new IllegalArgumentException ("Unknown font size hints name: " + name); 183 } 184 } | Popular Tags |