KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > html > 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.html;
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.4 2003/04/27 09:21:59 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 Area extends SinglePartElement implements Printable, FocusEvents, MouseEvents, KeyEvents
70 {
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     public static final String JavaDoc rect = "rect";
79     public static final String JavaDoc circle = "circle";
80     public static final String JavaDoc poly = "poly";
81     
82     /**
83         Private initialization routine.
84     */

85     {
86         setElementType("area");
87         setNoHref(true);
88     }
89     
90     /**
91         Basic constructor. Use the set* methods to set the values
92         of the attributes.
93     */

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

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

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

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

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

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

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

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

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

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

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

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

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

241     public Area setNoHref(boolean href)
242     {
243         if ( href == true )
244             addAttribute("nohref", NO_ATTRIBUTE_VALUE);
245         else
246             removeAttribute("nohref");
247             
248         return(this);
249     }
250
251     /**
252         Adds an Element to the element.
253         @param hashcode name of element for hash table
254         @param element Adds an Element to the element.
255      */

256     public Area addElement(String JavaDoc hashcode,Element element)
257     {
258         addElementToRegistry(hashcode,element);
259         return(this);
260     }
261
262     /**
263         Adds an Element to the element.
264         @param hashcode name of element for hash table
265         @param element Adds an Element to the element.
266      */

267     public Area addElement(String JavaDoc hashcode,String JavaDoc element)
268     {
269         addElementToRegistry(hashcode,element);
270         return(this);
271     }
272
273     /**
274         Add an element to the element
275         @param element a string representation of the element
276     */

277     public Area addElement(String JavaDoc element)
278     {
279         addElementToRegistry(element);
280         return(this);
281     }
282
283     /**
284         Add an element to the element
285         @param element an element to add
286     */

287     public Area addElement(Element element)
288     {
289         addElementToRegistry(element);
290         return(this);
291     }
292     /**
293         Removes an Element from the element.
294         @param hashcode the name of the element to be removed.
295     */

296     public Area removeElement(String JavaDoc hashcode)
297     {
298         removeElementFromRegistry(hashcode);
299         return(this);
300     }
301
302     /**
303         The onfocus event occurs when an element receives focus either by the
304         pointing device or by tabbing navigation. This attribute may be used
305         with the following elements: LABEL, INPUT, SELECT, TEXTAREA, and
306         BUTTON.
307         
308         @param The script
309     */

310     public void setOnFocus(String JavaDoc script)
311     {
312         addAttribute ( "onFocus", script );
313     }
314
315     /**
316         The onblur event occurs when an element loses focus either by the
317         pointing device or by tabbing navigation. It may be used with the same
318         elements as onfocus.
319         
320         @param The script
321     */

322     public void setOnBlur(String JavaDoc script)
323     {
324         addAttribute ( "onBlur", script );
325     }
326
327     /**
328         The onclick event occurs when the pointing device button is clicked
329         over an element. This attribute may be used with most elements.
330         
331         @param The script
332     */

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

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

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

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

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

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

393     public void setOnMouseOut(String JavaDoc script)
394     {
395         addAttribute ( "onMouseOut", script );
396     }
397
398     /**
399         The onkeypress event occurs when a key is pressed and released over an
400         element. This attribute may be used with most elements.
401         
402         @param The script
403     */

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

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

426     public void setOnKeyUp(String JavaDoc script)
427     {
428         addAttribute ( "onKeyUp", script );
429     }
430 }
431
Popular Tags