1 42 43 package org.jfree.xml.parser.coretypes; 44 45 import java.awt.Font ; 46 47 import org.jfree.xml.parser.AbstractXmlReadHandler; 48 import org.xml.sax.Attributes ; 49 import org.xml.sax.SAXException ; 50 51 54 public class FontReadHandler extends AbstractXmlReadHandler { 55 56 57 private Font font; 58 59 62 public FontReadHandler() { 63 super(); 64 } 65 66 74 protected void startParsing(final Attributes attrs) throws SAXException { 75 final String family = attrs.getValue("family"); 76 final int size = Integer.parseInt(attrs.getValue("size")); 77 final int style = getFontStyle(attrs.getValue("style")); 78 this.font = new Font (family, style, size); 79 } 80 81 88 private int getFontStyle (final String style) { 89 if ("bold-italic".equals(style)) { 90 return Font.BOLD | Font.ITALIC; 91 } 92 if ("bold".equals(style)) { 93 return Font.BOLD; 94 } 95 if ("italic".equals(style)) { 96 return Font.ITALIC; 97 } 98 return Font.PLAIN; 99 } 100 101 106 public Object getObject() { 107 return this.font; 108 } 109 110 } 111 | Popular Tags |