KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > IMG


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs.html;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates an &lt;IMG&gt; tag.
64
65     @version $Id: IMG.java,v 1.4 2003/04/27 09:20:29 rdonkin Exp $
66     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
67     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
68 */

69 public class IMG extends SinglePartElement implements Printable, MouseEvents, KeyEvents
70 {
71     /**
72             Private initialization routine.
73     */

74
75     {
76         setElementType("img");
77     }
78
79     /**
80         Basic constructor. Use the set* methods to set the attibutes.
81     */

82     public IMG()
83     {
84     }
85
86     /**
87         Creates an IMG tag
88
89         @param src the SRC="" attribute
90     */

91     public IMG(String JavaDoc src)
92     {
93         setSrc(src);
94     }
95
96     /**
97         Creates an IMG tag
98
99         @param src the SRC="" attribute
100         @param border the BORDER="" attribute
101     */

102     public IMG(String JavaDoc src, int border)
103     {
104         setSrc(src);
105         setBorder(border);
106     }
107
108     /**
109         Creates an IMG tag
110
111         @param src the SRC="" attribute
112         @param name the NAME="" attribute
113     */

114     public IMG(String JavaDoc src, String JavaDoc name)
115     {
116         setSrc(src);
117         setName(name);
118     }
119
120     /**
121         Creates an IMG tag
122
123         @param src the SRC="" attribute
124         @param name the NAME="" attribute
125         @param border the BORDER="" attribute
126     */

127     public IMG(String JavaDoc src, String JavaDoc name, int border)
128     {
129         setSrc(src);
130         setName(name);
131         setBorder(border);
132     }
133
134     /**
135         Sets the SRC="" attribute
136         @param src the SRC="" attribute
137     */

138     public IMG setSrc(String JavaDoc src)
139     {
140         addAttribute("src",src);
141         return this;
142     }
143
144     /**
145         Sets the BORDER="" attribute
146         @param border the BORDER="" attribute
147     */

148     public IMG setBorder(int border)
149     {
150         addAttribute("border",Integer.toString(border));
151         return this;
152     }
153
154     /**
155         Sets the NAME="" attribute
156         @param name the NAME="" attribute
157     */

158     public IMG setName(String JavaDoc name)
159     {
160         addAttribute("name",name);
161         return this;
162     }
163
164     /**
165         Sets the HEIGHT="" attribute
166         @param height the HEIGHT="" attribute
167     */

168     public IMG setHeight(String JavaDoc height)
169     {
170         addAttribute("height",height);
171         return this;
172     }
173
174     /**
175         Sets the HEIGHT="" attribute
176         @param height the HEIGHT="" attribute
177     */

178     public IMG setHeight(int height)
179     {
180         addAttribute("height",Integer.toString(height));
181         return this;
182     }
183
184     /**
185         Sets the WIDTH="" attribute
186         @param width the WIDTH="" attribute
187     */

188     public IMG setWidth(String JavaDoc width)
189     {
190         addAttribute("width",width);
191         return this;
192     }
193
194     /**
195         Sets the WIDTH="" attribute
196         @param width the WIDTH="" attribute
197     */

198     public IMG setWidth(int width)
199     {
200         addAttribute("width",Integer.toString(width));
201         return this;
202     }
203
204     /**
205         Sets the ALT="" attribute
206         @param alt the ALT="" attribute
207     */

208     public IMG setAlt(String JavaDoc alt)
209     {
210         addAttribute("alt",alt);
211         return this;
212     }
213
214     /**
215         Sets the ISMAP attribute
216         @param ismap the ISMAP attribute
217     */

218     public IMG setIsMap(boolean ismap)
219     {
220         if(ismap == true)
221             addAttribute("ismap",NO_ATTRIBUTE_VALUE);
222         else
223             removeAttribute("ismap");
224             
225         return this;
226     }
227
228     /**
229         Sets the USMAP="" attribute
230         @param usemap the USMAP="" attribute
231     */

232     public IMG setUseMap(String JavaDoc usemap)
233     {
234         addAttribute("usemap",usemap);
235         return this;
236     }
237
238     /**
239         Sets the ALIGN="" attribute
240         @param align the ALIGN="" attribute
241     */

242     public IMG setAlign(String JavaDoc align)
243     {
244         addAttribute("align",align);
245         return this;
246     }
247
248     /**
249         Sets the HSPACE="" attribute
250         @param hspace the HSPACE="" attribute
251     */

252     public IMG setHspace(String JavaDoc hspace)
253     {
254         addAttribute("hspace",hspace);
255         return this;
256     }
257
258     /**
259         Sets the HSPACE="" attribute
260         @param hspace the HSPACE="" attribute
261     */

262     public IMG setHspace(int hspace)
263     {
264         addAttribute("hspace",Integer.toString(hspace));
265         return this;
266     }
267
268     /**
269         Sets the VSPACE="" attribute
270         @param vspace the VSPACE="" attribute
271     */

272     public IMG setVspace(String JavaDoc vspace)
273     {
274         addAttribute("vspace",vspace);
275         return this;
276     }
277
278     /**
279         Sets the VSPACE="" attribute
280         @param vspace the VSPACE="" attribute
281     */

282     public IMG setVspace(int vspace)
283     {
284         addAttribute("vspace",Integer.toString(vspace));
285         return this;
286     }
287
288     /**
289         Adds an Element to the element.
290         @param hashcode name of element for hash table
291         @param element Adds an Element to the element.
292      */

293     public IMG addElement(String JavaDoc hashcode,Element element)
294     {
295         addElementToRegistry(hashcode,element);
296         return(this);
297     }
298
299     /**
300         Adds an Element to the element.
301         @param hashcode name of element for hash table
302         @param element Adds an Element to the element.
303      */

304     public IMG addElement(String JavaDoc hashcode,String JavaDoc element)
305     {
306         addElementToRegistry(hashcode,element);
307         return(this);
308     }
309
310     /**
311         Adds an Element to the element.
312         @param element Adds an Element to the element.
313      */

314     public IMG addElement(Element element)
315     {
316         addElementToRegistry(element);
317         return(this);
318     }
319
320     /**
321         Adds an Element to the element.
322         @param element Adds an Element to the element.
323      */

324     public IMG addElement(String JavaDoc element)
325     {
326         addElementToRegistry(element);
327         return(this);
328     }
329     /**
330         Removes an Element from the element.
331         @param hashcode the name of the element to be removed.
332     */

333     public IMG removeElement(String JavaDoc hashcode)
334     {
335         removeElementFromRegistry(hashcode);
336         return(this);
337     }
338
339     /**
340         The onclick event occurs when the pointing device button is clicked
341         over an element. This attribute may be used with most elements.
342         
343         @param The script
344     */

345     public void setOnClick(String JavaDoc script)
346     {
347         addAttribute ( "onClick", script );
348     }
349     /**
350         The ondblclick event occurs when the pointing device button is double
351         clicked over an element. This attribute may be used with most elements.
352
353         @param The script
354     */

355     public void setOnDblClick(String JavaDoc script)
356     {
357         addAttribute ( "onDblClick", script );
358     }
359     /**
360         The onmousedown event occurs when the pointing device button is pressed
361         over an element. This attribute may be used with most elements.
362
363         @param The script
364     */

365     public void setOnMouseDown(String JavaDoc script)
366     {
367         addAttribute ( "onMouseDown", script );
368     }
369     /**
370         The onmouseup event occurs when the pointing device button is released
371         over an element. This attribute may be used with most elements.
372
373         @param The script
374     */

375     public void setOnMouseUp(String JavaDoc script)
376     {
377         addAttribute ( "onMouseUp", script );
378     }
379     /**
380         The onmouseover event occurs when the pointing device is moved onto an
381         element. This attribute may be used with most elements.
382
383         @param The script
384     */

385     public void setOnMouseOver(String JavaDoc script)
386     {
387         addAttribute ( "onMouseOver", script );
388     }
389     /**
390         The onmousemove event occurs when the pointing device is moved while it
391         is over an element. This attribute may be used with most elements.
392
393         @param The script
394     */

395     public void setOnMouseMove(String JavaDoc script)
396     {
397         addAttribute ( "onMouseMove", script );
398     }
399     /**
400         The onmouseout event occurs when the pointing device is moved away from
401         an element. This attribute may be used with most elements.
402
403         @param The script
404     */

405     public void setOnMouseOut(String JavaDoc script)
406     {
407         addAttribute ( "onMouseOut", script );
408     }
409
410     /**
411         The onkeypress event occurs when a key is pressed and released over an
412         element. This attribute may be used with most elements.
413         
414         @param The script
415     */

416     public void setOnKeyPress(String JavaDoc script)
417     {
418         addAttribute ( "onKeyPress", script );
419     }
420
421     /**
422         The onkeydown event occurs when a key is pressed down over an element.
423         This attribute may be used with most elements.
424         
425         @param The script
426     */

427     public void setOnKeyDown(String JavaDoc script)
428     {
429         addAttribute ( "onKeyDown", script );
430     }
431
432     /**
433         The onkeyup event occurs when a key is released over an element. This
434         attribute may be used with most elements.
435         
436         @param The script
437     */

438     public void setOnKeyUp(String JavaDoc script)
439     {
440         addAttribute ( "onKeyUp", script );
441     }
442 }
443
Popular Tags