1 19 package jcckit.graphic; 20 21 import jcckit.util.ConfigParameters; 22 import jcckit.util.FactoryException; 23 24 import java.util.Hashtable ; 25 26 32 public class FontStyle { 33 private static final Hashtable REPOSITORY = new Hashtable (); 34 static final String NORMAL_TXT = "normal", 35 BOLD_TXT = "bold", 36 ITALIC_TXT = "italic", 37 BOLD_ITALIC_TXT = "bold italic"; 38 39 public static final FontStyle NORMAL = new FontStyle(NORMAL_TXT), 40 BOLD = new FontStyle(BOLD_TXT), 41 ITALIC = new FontStyle(ITALIC_TXT), 42 BOLD_ITALIC = new FontStyle(BOLD_ITALIC_TXT); 43 44 private final String _description; 45 46 47 private FontStyle(String description) { 48 _description = description; 49 REPOSITORY.put(description, this); 50 } 51 52 65 public static FontStyle getFontStyle(ConfigParameters config, String key, 66 FontStyle defaultValue) { 67 FontStyle result = defaultValue; 68 String value = config.get(key, null); 69 if (value != null) { 70 result = (FontStyle) REPOSITORY.get(value); 71 if (result == null) { 72 throw new FactoryException(config, key, "Invalid font style."); 73 } 74 } 75 return result; 76 } 77 78 79 public String toString() { 80 return _description; 81 } 82 } 83 | Popular Tags |