KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > xhtml > area


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.xhtml;
59
60 import org.apache.ecs.*;
61
62 /**
63     This class creates a &lt;area&gt; tag.
64
65     @version $Id: area.java,v 1.2 2003/04/27 09:41:09 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     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
69 */

70 public class area extends SinglePartElement implements Printable, FocusEvents, MouseEvents, KeyEvents
71 {
72     public static final String JavaDoc DEFAULT = "default";
73
74     public static final String JavaDoc rect = "rect";
75     public static final String JavaDoc circle = "circle";
76     public static final String JavaDoc poly = "poly";
77     
78     /**
79         Private initialization routine.
80     */

81     {
82         setElementType("area");
83         setCase(LOWERCASE);
84         setAttributeQuote(true);
85         setBeginEndModifier('/');
86         setNoHref(true);
87     }
88     
89     /**
90         Basic constructor. Use the set* methods to set the values
91         of the attributes.
92     */

93     public area()
94     {
95     }
96
97     /**
98         Use the set* methods to set the values
99         of the attributes.
100
101         @param shape the shape="" attribute
102     */

103     public area(String JavaDoc shape)
104     {
105         setShape(shape);
106     }
107
108     /**
109         Use the set* methods to set the values
110         of the attributes.
111
112         @param shape the shape="" attribute
113         @param coords the coords="" attribute
114     */

115     public area(String JavaDoc shape, String JavaDoc coords)
116     {
117         setShape(shape);
118         setCoords(coords);
119     }
120
121     /**
122         Use the set* methods to set the values
123         of the attributes.
124
125         @param shape the shape="" attribute
126         @param coords the coords="" attribute
127     */

128     public area(String JavaDoc shape, int[] coords)
129     {
130         setShape(shape);
131         setCoords(coords);
132     }
133
134     /**
135         Use the set* methods to set the values
136         of the attributes.
137
138         @param shape the shape="" attribute
139         @param coords the coords="" attribute
140         @param href the HREF="" attribute
141     */

142     public area(String JavaDoc shape, String JavaDoc coords, String JavaDoc href)
143     {
144         setShape(shape);
145         setCoords(coords);
146         setHref(href);
147     }
148
149     /**
150         Use the set* methods to set the values
151         of the attributes.
152
153         @param shape the shape="" attribute
154         @param coords the coords="" attribute
155         @param href the HREF="" attribute
156     */

157     public area(String JavaDoc shape, int[] coords, String JavaDoc href)
158     {
159         setShape(shape);
160         setCoords(coords);
161         setHref(href);
162     }
163
164     /**
165         Sets the shape="" attribute
166         @param shape the shape="" attribute
167     */

168     public area setShape(String JavaDoc shape)
169     {
170         addAttribute("shape",shape);
171         return this;
172     }
173
174     /**
175         Sets the coords="" attribute
176         @param coords the coords="" attribute
177     */

178     public area setCoords(String JavaDoc coords)
179     {
180         addAttribute("coords",coords);
181         return this;
182     }
183     
184     /**
185         Sets the coords="" attribute
186         @param coords the coords="" attribute
187     */

188     public area setCoords(int[] coords)
189     {
190         addAttribute("coords", coords[0] + "," + coords[1] + "," +
191                                       coords[2] + "," + coords[3]);
192         return this;
193     }
194
195     /**
196         Sets the HREF="" attribute
197         @param href the HREF="" attribute
198     */

199     public area setHref(String JavaDoc href)
200     {
201         addAttribute("href",href);
202         setNoHref(false);
203         return this;
204     }
205     
206     /**
207         Sets the alt="" attribute
208         @param alt the alt="" attribute
209     */

210     public area setAlt(String JavaDoc alt)
211     {
212         addAttribute("alt",alt);
213         return this;
214     }
215     
216     /**
217         Sets the tabindex="" attribute
218         @param alt the tabindex="" attribute
219     */

220     public area setTabindex(String JavaDoc index)
221     {
222         addAttribute("tabindex",index);
223         return this;
224     }
225     
226     /**
227         Sets the tabindex="" attribute
228         @param alt the tabindex="" attribute
229     */

230     public area setTabindex(int index)
231     {
232         setTabindex(Integer.toString(index));
233         return this;
234     }
235     
236     /**
237         Sets the nohref
238         @param href true or false
239     */

240     public area setNoHref(boolean href)
241     {
242         if ( href == true )
243             addAttribute("nohref", "nohref");
244         else
245             removeAttribute("nohref");
246             
247         return(this);
248     }
249
250     /**
251         Sets the lang="" and xml:lang="" attributes
252         @param lang the lang="" and xml:lang="" attributes
253     */

254     public Element setLang(String JavaDoc lang)
255     {
256         addAttribute("lang",lang);
257         addAttribute("xml:lang",lang);
258         return this;
259     }
260
261     /**
262         Adds an Element to the element.
263         @param hashcode name of element for hash table
264         @param element Adds an Element to the element.
265      */

266     public area addElement(String JavaDoc hashcode,Element element)
267     {
268         addElementToRegistry(hashcode,element);
269         return(this);
270     }
271
272     /**
273         Adds an Element to the element.
274         @param hashcode name of element for hash table
275         @param element Adds an Element to the element.
276      */

277     public area addElement(String JavaDoc hashcode,String JavaDoc element)
278     {
279         addElementToRegistry(hashcode,element);
280         return(this);
281     }
282
283     /**
284         Add an element to the element
285         @param element a string representation of the element
286     */

287     public area addElement(String JavaDoc element)
288     {
289         addElementToRegistry(element);
290         return(this);
291     }
292
293     /**
294         Add an element to the element
295         @param element an element to add
296     */

297     public area addElement(Element element)
298     {
299         addElementToRegistry(element);
300         return(this);
301     }
302     /**
303         Removes an Element from the element.
304         @param hashcode the name of the element to be removed.
305     */

306     public area removeElement(String JavaDoc hashcode)
307     {
308         removeElementFromRegistry(hashcode);
309         return(this);
310     }
311
312     /**
313         The onfocus event occurs when an element receives focus either by the
314         pointing device or by tabbing navigation. This attribute may be used
315         with the following elements: LABEL, INPUT, SELECT, TEXTAREA, and
316         BUTTON.
317         
318         @param The script
319     */

320     public void setOnFocus(String JavaDoc script)
321     {
322         addAttribute ( "onfocus", script );
323     }
324
325     /**
326         The onblur event occurs when an element loses focus either by the
327         pointing device or by tabbing navigation. It may be used with the same
328         elements as onfocus.
329         
330         @param The script
331     */

332     public void setOnBlur(String JavaDoc script)
333     {
334         addAttribute ( "onblur", script );
335     }
336
337     /**
338         The onclick event occurs when the pointing device button is clicked
339         over an element. This attribute may be used with most elements.
340         
341         @param The script
342     */

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

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

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

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

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

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

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

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

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

436     public void setOnKeyUp(String JavaDoc script)
437     {
438         addAttribute ( "onkeyup", script );
439     }
440 }
441
Popular Tags