KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jasperreports > engine > xml > JRPrintImageFactory


1 /*
2  * ============================================================================
3  * GNU Lesser General Public License
4  * ============================================================================
5  *
6  * JasperReports - Free Java report-generating library.
7  * Copyright (C) 2001-2006 JasperSoft Corporation http://www.jaspersoft.com
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22  *
23  * JasperSoft Corporation
24  * 303 Second Street, Suite 450 North
25  * San Francisco, CA 94107
26  * http://www.jaspersoft.com
27  */

28 package net.sf.jasperreports.engine.xml;
29
30 import net.sf.jasperreports.engine.JasperPrint;
31 import net.sf.jasperreports.engine.base.JRBasePrintImage;
32
33 import org.xml.sax.Attributes JavaDoc;
34
35
36 /**
37  * @author Teodor Danciu (teodord@users.sourceforge.net)
38  * @version $Id: JRPrintImageFactory.java 1364 2006-08-31 18:13:20 +0300 (Thu, 31 Aug 2006) lucianc $
39  */

40 public class JRPrintImageFactory extends JRBaseFactory
41 {
42
43
44     /**
45      *
46      */

47     private static final String JavaDoc ATTRIBUTE_scaleImage = "scaleImage";
48     private static final String JavaDoc ATTRIBUTE_hAlign = "hAlign";
49     private static final String JavaDoc ATTRIBUTE_vAlign = "vAlign";
50     private static final String JavaDoc ATTRIBUTE_isLazy = "isLazy";
51     private static final String JavaDoc ATTRIBUTE_onErrorType = "onErrorType";
52     private static final String JavaDoc ATTRIBUTE_hyperlinkType = "hyperlinkType";
53     private static final String JavaDoc ATTRIBUTE_hyperlinkTarget = "hyperlinkTarget";
54     private static final String JavaDoc ATTRIBUTE_anchorName = "anchorName";
55     private static final String JavaDoc ATTRIBUTE_hyperlinkReference = "hyperlinkReference";
56     private static final String JavaDoc ATTRIBUTE_hyperlinkAnchor = "hyperlinkAnchor";
57     private static final String JavaDoc ATTRIBUTE_hyperlinkPage = "hyperlinkPage";
58     public static final String JavaDoc ATTRIBUTE_hyperlinkTooltip = "hyperlinkTooltip";
59     private static final String JavaDoc ATTRIBUTE_bookmarkLevel = "bookmarkLevel";
60
61
62     /**
63      *
64      */

65     public Object JavaDoc createObject(Attributes JavaDoc atts)
66     {
67         JasperPrint jasperPrint = (JasperPrint)digester.peek(digester.getCount() - 2);
68
69         JRBasePrintImage image = new JRBasePrintImage(jasperPrint.getDefaultStyleProvider());
70
71         Byte JavaDoc scaleImage = (Byte JavaDoc)JRXmlConstants.getScaleImageMap().get(atts.getValue(ATTRIBUTE_scaleImage));
72         if (scaleImage != null)
73         {
74             image.setScaleImage(scaleImage);
75         }
76
77         Byte JavaDoc horizontalAlignment = (Byte JavaDoc)JRXmlConstants.getHorizontalAlignMap().get(atts.getValue(ATTRIBUTE_hAlign));
78         if (horizontalAlignment != null)
79         {
80             image.setHorizontalAlignment(horizontalAlignment);
81         }
82
83         Byte JavaDoc verticalAlignment = (Byte JavaDoc)JRXmlConstants.getVerticalAlignMap().get(atts.getValue(ATTRIBUTE_vAlign));
84         if (verticalAlignment != null)
85         {
86             image.setVerticalAlignment(verticalAlignment);
87         }
88
89         String JavaDoc isLazy = atts.getValue(ATTRIBUTE_isLazy);
90         if (isLazy != null && isLazy.length() > 0)
91         {
92             image.setLazy(Boolean.valueOf(isLazy).booleanValue());
93         }
94
95         Byte JavaDoc onErrorType = (Byte JavaDoc)JRXmlConstants.getOnErrorTypeMap().get(atts.getValue(ATTRIBUTE_onErrorType));
96         if (onErrorType != null)
97         {
98             image.setOnErrorType(onErrorType.byteValue());
99         }
100
101         String JavaDoc hyperlinkType = atts.getValue(ATTRIBUTE_hyperlinkType);
102         if (hyperlinkType != null)
103         {
104             image.setLinkType(hyperlinkType);
105         }
106
107         Byte JavaDoc hyperlinkTarget = (Byte JavaDoc)JRXmlConstants.getHyperlinkTargetMap().get(atts.getValue(ATTRIBUTE_hyperlinkTarget));
108         if (hyperlinkTarget != null)
109         {
110             image.setHyperlinkTarget(hyperlinkTarget.byteValue());
111         }
112
113         image.setAnchorName(atts.getValue(ATTRIBUTE_anchorName));
114         image.setHyperlinkReference(atts.getValue(ATTRIBUTE_hyperlinkReference));
115         image.setHyperlinkAnchor(atts.getValue(ATTRIBUTE_hyperlinkAnchor));
116         
117         String JavaDoc hyperlinkPage = atts.getValue(ATTRIBUTE_hyperlinkPage);
118         if (hyperlinkPage != null)
119         {
120             image.setHyperlinkPage(new Integer JavaDoc(hyperlinkPage));
121         }
122         
123         image.setHyperlinkTooltip(atts.getValue(ATTRIBUTE_hyperlinkTooltip));
124
125         String JavaDoc bookmarkLevelAttr = atts.getValue(ATTRIBUTE_bookmarkLevel);
126         if (bookmarkLevelAttr != null)
127         {
128             image.setBookmarkLevel(Integer.parseInt(bookmarkLevelAttr));
129         }
130
131         return image;
132     }
133     
134
135 }
136
Popular Tags