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.JasperPrint;
031: import net.sf.jasperreports.engine.base.JRBasePrintImage;
032:
033: import org.xml.sax.Attributes;
034:
035: /**
036: * @author Teodor Danciu (teodord@users.sourceforge.net)
037: * @version $Id: JRPrintImageFactory.java 1581 2007-02-12 14:19:02Z shertage $
038: */
039: public class JRPrintImageFactory extends JRBaseFactory {
040:
041: /**
042: *
043: */
044: public Object createObject(Attributes atts) {
045: JasperPrint jasperPrint = (JasperPrint) digester.peek(digester
046: .getCount() - 2);
047:
048: JRBasePrintImage image = new JRBasePrintImage(jasperPrint
049: .getDefaultStyleProvider());
050:
051: Byte scaleImage = (Byte) JRXmlConstants.getScaleImageMap().get(
052: atts.getValue(JRXmlConstants.ATTRIBUTE_scaleImage));
053: if (scaleImage != null) {
054: image.setScaleImage(scaleImage);
055: }
056:
057: Byte horizontalAlignment = (Byte) JRXmlConstants
058: .getHorizontalAlignMap().get(
059: atts.getValue(JRXmlConstants.ATTRIBUTE_hAlign));
060: if (horizontalAlignment != null) {
061: image.setHorizontalAlignment(horizontalAlignment);
062: }
063:
064: Byte verticalAlignment = (Byte) JRXmlConstants
065: .getVerticalAlignMap().get(
066: atts.getValue(JRXmlConstants.ATTRIBUTE_vAlign));
067: if (verticalAlignment != null) {
068: image.setVerticalAlignment(verticalAlignment);
069: }
070:
071: String isLazy = atts.getValue(JRXmlConstants.ATTRIBUTE_isLazy);
072: if (isLazy != null && isLazy.length() > 0) {
073: image.setLazy(Boolean.valueOf(isLazy).booleanValue());
074: }
075:
076: Byte onErrorType = (Byte) JRXmlConstants
077: .getOnErrorTypeMap()
078: .get(
079: atts
080: .getValue(JRXmlConstants.ATTRIBUTE_onErrorType));
081: if (onErrorType != null) {
082: image.setOnErrorType(onErrorType.byteValue());
083: }
084:
085: String hyperlinkType = atts
086: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkType);
087: if (hyperlinkType != null) {
088: image.setLinkType(hyperlinkType);
089: }
090:
091: Byte hyperlinkTarget = (Byte) JRXmlConstants
092: .getHyperlinkTargetMap()
093: .get(
094: atts
095: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTarget));
096: if (hyperlinkTarget != null) {
097: image.setHyperlinkTarget(hyperlinkTarget.byteValue());
098: }
099:
100: image.setAnchorName(atts
101: .getValue(JRXmlConstants.ATTRIBUTE_anchorName));
102: image.setHyperlinkReference(atts
103: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkReference));
104: image.setHyperlinkAnchor(atts
105: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkAnchor));
106:
107: String hyperlinkPage = atts
108: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkPage);
109: if (hyperlinkPage != null) {
110: image.setHyperlinkPage(new Integer(hyperlinkPage));
111: }
112:
113: image.setHyperlinkTooltip(atts
114: .getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTooltip));
115:
116: String bookmarkLevelAttr = atts
117: .getValue(JRXmlConstants.ATTRIBUTE_bookmarkLevel);
118: if (bookmarkLevelAttr != null) {
119: image.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));
120: }
121:
122: return image;
123: }
124:
125: }
|