1 33 34 package edu.rice.cs.drjava.config; 35 36 import java.awt.Font ; 37 38 42 public class FontOption extends Option<Font > { 43 44 public FontOption(String key, Font def) { super(key,def); } 45 46 50 public Font parse(String s) { 51 String newS = s; int idx = newS.indexOf("PLAIN-"); 53 while (idx != -1) { 54 newS = newS.substring(0, idx) + newS.substring(idx + 6); 55 idx = newS.indexOf("PLAIN-"); 56 } 57 return Font.decode(newS); } 59 60 61 public String format(Font f) { 62 final StringBuilder str = new StringBuilder (f.getName()); 63 str.append("-"); 64 if (f.isBold()) { 65 str.append("BOLD"); 66 } 67 if (f.isItalic()) { 68 str.append("ITALIC"); 69 } 70 if (! f.isPlain()) { 74 str.append("-"); 75 } 76 str.append(f.getSize()); 77 78 return str.toString(); 79 } 80 } | Popular Tags |