001: /*
002: * ============================================================================
003: * GNU Lesser General Public License
004: * ============================================================================
005: *
006: * JasperReports - Free Java report-generating library.
007: * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2.1 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
022: *
023: * JasperSoft Corporation
024: * 303 Second Street, Suite 450 North
025: * San Francisco, CA 94107
026: * http://www.jaspersoft.com
027: */
028: package net.sf.jasperreports.engine.xml;
029:
030: import net.sf.jasperreports.engine.design.JRDesignReportFont;
031:
032: import org.xml.sax.Attributes;
033:
034: /**
035: * @author Teodor Danciu (teodord@users.sourceforge.net)
036: * @version $Id: JRReportFontFactory.java 1581 2007-02-12 14:19:02Z shertage $
037: */
038: public class JRReportFontFactory extends JRBaseFactory {
039:
040: /**
041: *
042: */
043: public Object createObject(Attributes atts) {
044: JRDesignReportFont reportFont = new JRDesignReportFont();
045:
046: reportFont
047: .setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name));
048:
049: String isDefault = atts
050: .getValue(JRXmlConstants.ATTRIBUTE_isDefault);
051: if (isDefault != null && isDefault.length() > 0) {
052: reportFont.setDefault(Boolean.valueOf(isDefault)
053: .booleanValue());
054: }
055:
056: reportFont.setFontName(atts
057: .getValue(JRXmlConstants.ATTRIBUTE_fontName));
058:
059: String isBold = atts.getValue(JRXmlConstants.ATTRIBUTE_isBold);
060: if (isBold != null && isBold.length() > 0) {
061: reportFont.setBold(Boolean.valueOf(isBold));
062: }
063:
064: String isItalic = atts
065: .getValue(JRXmlConstants.ATTRIBUTE_isItalic);
066: if (isItalic != null && isItalic.length() > 0) {
067: reportFont.setItalic(Boolean.valueOf(isItalic));
068: }
069:
070: String isUnderline = atts
071: .getValue(JRXmlConstants.ATTRIBUTE_isUnderline);
072: if (isUnderline != null && isUnderline.length() > 0) {
073: reportFont.setUnderline(Boolean.valueOf(isUnderline));
074: }
075:
076: String isStrikeThrough = atts
077: .getValue(JRXmlConstants.ATTRIBUTE_isStrikeThrough);
078: if (isStrikeThrough != null && isStrikeThrough.length() > 0) {
079: reportFont.setStrikeThrough(Boolean
080: .valueOf(isStrikeThrough));
081: }
082:
083: String size = atts.getValue(JRXmlConstants.ATTRIBUTE_size);
084: if (size != null && size.length() > 0) {
085: reportFont.setFontSize(Integer.parseInt(size));
086: }
087:
088: reportFont.setPdfFontName(atts
089: .getValue(JRXmlConstants.ATTRIBUTE_pdfFontName));
090: reportFont.setPdfEncoding(atts
091: .getValue(JRXmlConstants.ATTRIBUTE_pdfEncoding));
092:
093: String isPdfEmbedded = atts
094: .getValue(JRXmlConstants.ATTRIBUTE_isPdfEmbedded);
095: if (isPdfEmbedded != null && isPdfEmbedded.length() > 0) {
096: reportFont.setPdfEmbedded(Boolean.valueOf(isPdfEmbedded));
097: }
098:
099: return reportFont;
100: }
101:
102: }
|