2
* JasperReports - Free Java Reporting Library.
3
* Copyright (C) 2001 - 2009 Jaspersoft Corporation. All rights reserved.
4
* http://www.jaspersoft.com
6
* Unless you have purchased a commercial license agreement from Jaspersoft,
7
* the following license terms apply:
9
* This program is part of JasperReports.
11
* JasperReports is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU Lesser General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
16
* JasperReports is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public License
22
* along with JasperReports. If not, see <http://www.gnu.org/licenses/>.
24
package net.sf.jasperreports.engine.xml;
26
import net.sf.jasperreports.engine.design.JRDesignGroup;
27
import net.sf.jasperreports.engine.design.JRDesignImage;
28
import net.sf.jasperreports.engine.design.JasperDesign;
29
import net.sf.jasperreports.engine.type.EvaluationTimeEnum;
30
import net.sf.jasperreports.engine.type.HorizontalAlignEnum;
31
import net.sf.jasperreports.engine.type.OnErrorTypeEnum;
32
import net.sf.jasperreports.engine.type.ScaleImageEnum;
33
import net.sf.jasperreports.engine.type.VerticalAlignEnum;
35
import org.xml.sax.Attributes;
39
* @author Teodor Danciu (teodord@users.sourceforge.net)
40
* @version $Id: JRImageFactory.java 3701 2010-04-07 11:09:35Z lucianc $
42
public class JRImageFactory extends JRBaseFactory
48
public Object createObject(Attributes atts)
50
JRXmlLoader xmlLoader = (JRXmlLoader)digester.peek(digester.getCount() - 1);
51
JasperDesign jasperDesign = (JasperDesign)digester.peek(digester.getCount() - 2);
53
JRDesignImage image = new JRDesignImage(jasperDesign);
55
// get image attributes
56
ScaleImageEnum scaleImage = ScaleImageEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_scaleImage));
57
if (scaleImage != null)
59
image.setScaleImage(scaleImage);
62
HorizontalAlignEnum horizontalAlignment = HorizontalAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_hAlign));
63
if (horizontalAlignment != null)
65
image.setHorizontalAlignment(horizontalAlignment);
68
VerticalAlignEnum verticalAlignment = VerticalAlignEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_vAlign));
69
if (verticalAlignment != null)
71
image.setVerticalAlignment(verticalAlignment);
74
String isUsingCache = atts.getValue(JRXmlConstants.ATTRIBUTE_isUsingCache);
75
if (isUsingCache != null && isUsingCache.length() > 0)
77
image.setUsingCache(Boolean.valueOf(isUsingCache));
80
String isLazy = atts.getValue(JRXmlConstants.ATTRIBUTE_isLazy);
81
if (isLazy != null && isLazy.length() > 0)
83
image.setLazy(Boolean.valueOf(isLazy).booleanValue());
86
OnErrorTypeEnum onErrorType = OnErrorTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_onErrorType));
87
if (onErrorType != null)
89
image.setOnErrorType(onErrorType);
92
EvaluationTimeEnum evaluationTime = EvaluationTimeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationTime));
93
if (evaluationTime != null)
95
image.setEvaluationTime(evaluationTime);
97
if (image.getEvaluationTimeValue() == EvaluationTimeEnum.GROUP)
99
xmlLoader.addGroupEvaluatedImage(image);
101
String groupName = atts.getValue(JRXmlConstants.ATTRIBUTE_evaluationGroup);
102
if (groupName != null)
104
JRDesignGroup group = new JRDesignGroup();
105
group.setName(groupName);
106
image.setEvaluationGroup(group);
110
image.setLinkType(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkType));
111
image.setLinkTarget(atts.getValue(JRXmlConstants.ATTRIBUTE_hyperlinkTarget));
113
String bookmarkLevelAttr = atts.getValue(JRXmlConstants.ATTRIBUTE_bookmarkLevel);
114
if (bookmarkLevelAttr != null)
116
image.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));