KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > taglib > common > TextRenderTag


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23 package org.infoglue.deliver.taglib.common;
24
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import javax.servlet.jsp.JspException JavaDoc;
29
30 import org.infoglue.deliver.taglib.component.ComponentLogicTag;
31
32 /**
33  * A Tag used for rendering images from text. Using the functionality
34  * in BasicTemplateController and ComponentLogic.
35  * @see rg.infoglue.deliver.util.graphics.AdvancedImageRenderer
36  * @author Per Jonsson per.jonsson@it-huset.se
37  */

38 public class TextRenderTag extends ComponentLogicTag
39 {
40     private static final long serialVersionUID = 523722286871322906L;
41
42     private Object JavaDoc result;
43
44     private String JavaDoc text = null;
45
46     private String JavaDoc propertyName = null;
47
48     private Integer JavaDoc contentId = null;
49
50     private Map JavaDoc renderAttributes = null;
51
52     public TextRenderTag()
53     {
54         super();
55     }
56
57     public int doEndTag() throws JspException JavaDoc
58     {
59         if ( contentId != null )
60         {
61             result = this.getController().getRenderedTextUrl( contentId, text, renderAttributes );
62         }
63         else if ( propertyName != null )
64         {
65             result = this.getComponentLogic().getRenderedTextUrl( propertyName, text, renderAttributes );
66         }
67         else
68         {
69             result = this.getController().getRenderedTextUrl( text, renderAttributes );
70         }
71
72         this.produceResult( result );
73
74         return EVAL_PAGE;
75     }
76
77     private void setAttribute( String JavaDoc key, Object JavaDoc value )
78     {
79         if ( renderAttributes == null )
80         {
81             renderAttributes = new HashMap JavaDoc();
82         }
83         if ( key != null && value != null )
84         {
85             renderAttributes.put( key, value.toString() );
86         }
87     }
88
89     /**
90      * @param propertyName The propertyName to set.
91      */

92     public void setPropertyName( String JavaDoc propertyName ) throws JspException JavaDoc
93     {
94         this.propertyName = evaluateString( "textRender", "propertyName", propertyName );
95     }
96
97     /**
98      * @param contentId The contentId to set.
99      */

100     public void setContentId( final String JavaDoc contentId ) throws JspException JavaDoc
101     {
102         this.contentId = evaluateInteger( "textRender", "contentId", contentId );
103     }
104
105     /**
106      * @param text The text to set.
107      */

108     public void setText( String JavaDoc text ) throws JspException JavaDoc
109     {
110         this.text = evaluateString( "textRender", "text", text );
111     }
112
113     /**
114      * @param align The align to set.
115      */

116     public void setAlign( String JavaDoc align ) throws JspException JavaDoc
117     {
118         this.setAttribute( "align", evaluateInteger( "textRender", "align", align ) );
119     }
120
121     /**
122      * @param backgroundImageUrl The backgroundImageUrl to set.
123      */

124     public void setBackgroundImageUrl( String JavaDoc backgroundImageUrl ) throws JspException JavaDoc
125     {
126         this.setAttribute( "backgroundImageUrl",
127                 evaluateString( "textRender", "backgroundImageUrl", backgroundImageUrl ) );
128     }
129
130     /**
131      * @param bgColor The bgColor to set.
132      */

133     public void setBgColor( String JavaDoc bgColor ) throws JspException JavaDoc
134     {
135         this.setAttribute( "bgColor", evaluateString( "textRender", "bgColor", bgColor ) );
136     }
137
138     /**
139      * @param fgColor The fgColor to set.
140      */

141     public void setFgColor( String JavaDoc fgColor ) throws JspException JavaDoc
142     {
143         this.setAttribute( "fgColor", evaluateString( "textRender", "fgColor", fgColor ) );
144     }
145
146     /**
147      * @param fontName The fontName to set.
148      */

149     public void setFontName( String JavaDoc fontName ) throws JspException JavaDoc
150     {
151         this.setAttribute( "fontName", evaluateString( "textRender", "fontName", fontName ) );
152     }
153
154     /**
155      * @param fontSize The fontSize to set.
156      */

157     public void setFontSize( String JavaDoc fontSize ) throws JspException JavaDoc
158     {
159         this.setAttribute( "fontSize", evaluateInteger( "textRender", "fontSize", fontSize ) );
160     }
161
162     /**
163      * @param fontStyle The fontStyle to set.
164      */

165     public void setFontStyle( String JavaDoc fontStyle ) throws JspException JavaDoc
166     {
167         this.setAttribute( "fontStyle", evaluateInteger( "textRender", "fontStyle", fontStyle ) );
168     }
169
170     /**
171      * @param imageType The imageType to set.
172      */

173     public void setImageType( String JavaDoc imageType ) throws JspException JavaDoc
174     {
175         this.setAttribute( "imageType", evaluateInteger( "textRender", "imageType", imageType ) );
176     }
177
178     /**
179      * @param maxRows The maxRows to set.
180      */

181     public void setMaxRows( String JavaDoc maxRows ) throws JspException JavaDoc
182     {
183         this.setAttribute( "maxRows", evaluateInteger( "textRender", "maxRows", maxRows ) );
184     }
185
186     /**
187      * @param pad The pad to set.
188      */

189     public void setPad( String JavaDoc pad ) throws JspException JavaDoc
190     {
191         this.setAttribute( "pad", evaluateInteger( "textRender", "pad", pad ) );
192     }
193
194     /**
195      * @param padBottom The padBottom to set.
196      */

197     public void setPadBottom( String JavaDoc padBottom ) throws JspException JavaDoc
198     {
199         this.setAttribute( "padBottom", evaluateInteger( "textRender", "padBottom", padBottom ) );
200     }
201
202     /**
203      * @param padLeft The padLeft to set.
204      */

205     public void setPadLeft( String JavaDoc padLeft ) throws JspException JavaDoc
206     {
207         this.setAttribute( "padLeft", evaluateInteger( "textRender", "padLeft", padLeft ) );
208     }
209
210     /**
211      * @param padRight The padRight to set.
212      */

213     public void setPadRight( String JavaDoc padRight ) throws JspException JavaDoc
214     {
215         this.setAttribute( "padRight", evaluateInteger( "textRender", "padRight", padRight ) );
216     }
217
218     /**
219      * @param padTop The padTop to set.
220      */

221     public void setPadTop( String JavaDoc padTop ) throws JspException JavaDoc
222     {
223         this.setAttribute( "padTop", evaluateInteger( "textRender", "padTop", padTop ) );
224     }
225
226     /**
227      * @param renderWidth The renderWidth to set.
228      */

229     public void setRenderWidth( String JavaDoc renderWidth ) throws JspException JavaDoc
230     {
231         this.setAttribute( "renderWidth", evaluateInteger( "textRender", "renderWidth", renderWidth ) );
232     }
233
234     /**
235      * @param tileBackgroundImage The tileBackgroundImage to set.
236      */

237     public void setTileBackgroundImage( String JavaDoc tileBackgroundImage ) throws JspException JavaDoc
238     {
239         this.setAttribute( "tileBackgroundImage", evaluateInteger( "textRender", "tileBackgroundImage",
240                 tileBackgroundImage ) );
241     }
242
243     /**
244      * @param trimEdges The trimEdges to set.
245      */

246     public void setTrimEdges( String JavaDoc trimEdges ) throws JspException JavaDoc
247     {
248         this.setAttribute( "trimEdges", evaluateInteger( "textRender", "trimEdges", trimEdges ) );
249     }
250 }
Popular Tags