KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lamatek > tags > google > GoogleMapBoxTag


1 package com.lamatek.tags.google;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.Vector JavaDoc;
5
6 import javax.servlet.jsp.tagext.Tag JavaDoc;
7 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
8
9 /**
10  * GoogleMapBoxTag
11  *
12  * This class represents a <googlemaps:box> tag. Developers should not override this
13  * class.
14  *
15  * @author Tom Cole
16  * @version 0.40
17  */

18 public class GoogleMapBoxTag extends TagSupport JavaDoc implements Serializable JavaDoc, GoogleMapEventListener {
19
20     String JavaDoc color = "#ff0000";
21     int weight = 2;
22     float opacity = 0.50f;
23     String JavaDoc pointlist = null;
24     Vector JavaDoc points = null;
25     Vector JavaDoc events = null;
26     /**
27      * Overrides doStartTag() in TagSupport. Developers should not override this method.
28      */

29     public int doStartTag() {
30         Tag JavaDoc tag = this;
31         while (tag.getParent() != null) {
32             if (tag.getParent() instanceof GoogleMapTag) {
33                 ((GoogleMapTag) tag.getParent()).addBox(this);
34                 return SKIP_BODY;
35             }
36             tag = tag.getParent();
37         }
38         return SKIP_BODY;
39     }
40     /**
41      * Sets the color used (in hexadecimal form) to draw this box.
42      *
43      * @param color The color in hexadecimal format.
44      */

45     public void setColor(String JavaDoc color) {
46         this.color = color;
47     }
48     /**
49      * Sets the width of the line used to draw this box.
50      *
51      * @param weight The line width in pixels.
52      */

53     public void setWeight(int weight) {
54         this.weight = weight;
55     }
56     /**
57      * Returns the 0-1 based opacity of the line used to draw this box.
58      *
59      * @return The opacity of this box from 0 to 1.
60      */

61     public float getOpacity() {
62         return opacity;
63     }
64     /**
65      * Sets the 0-1 based opacity of the line used to draw this box.
66      *
67      * @param opacity A float from 0-1.
68      */

69     public void setOpacity(float opacity) {
70         this.opacity = opacity;
71     }
72     /**
73      * Returns the list of points used to draw this box.
74      *
75      * @return A comma separated list of point ids.
76      */

77     public String JavaDoc getPointlist() {
78         return pointlist;
79     }
80     /**
81      * Sets the list of points used to draw this box.
82      *
83      * @param pointlist A comma separated list of point ids.
84      */

85     public void setPointlist(String JavaDoc pointlist) {
86         this.pointlist = pointlist;
87         points = new Vector JavaDoc();
88         String JavaDoc[] p = pointlist.split(",");
89         for (int i = 0; i < p.length; i++) {
90             points.add(p[i].trim());
91         }
92     }
93     /**
94      * Returns the number of points used to draw this box.
95      *
96      * @return The number of points in this box.
97      */

98     public int pointCount() {
99         if (points == null)
100             return 0;
101         else
102             return points.size();
103     }
104     /**
105      * Returns the points stored at the supplied iteration.
106      *
107      * @param p The interator.
108      * @return The id of the point at the requested iteration.
109      */

110     public String JavaDoc getPoint(int p) {
111         if (points == null)
112             return null;
113         else
114             return (String JavaDoc) points.elementAt(p);
115     }
116     /**
117      * Returns the color of the line used to draw this box.
118      *
119      * @return The color in hexadecimal format.
120      */

121     public String JavaDoc getColor() {
122         return color;
123     }
124     /**
125      * Returns the weight of the line used to draw this box.
126      *
127      * @return The line width in pixels.
128      */

129     public int getWeight() {
130         return weight;
131     }
132     /**
133      * Adds an event listener to this overlay.
134      *
135      * @param event A GoogleMapEventTag
136      */

137     public void addEvent(GoogleMapEventTag event) {
138         if (events == null)
139             events = new Vector JavaDoc();
140         events.add(event);
141     }
142     /**
143      * Returns the list of currently registered event listeners
144      * for this overlay.
145      *
146      * @return A Vector of GoogleMapEventTags
147      */

148     public Vector JavaDoc getEvents() {
149         return events;
150     }
151 }
152
Popular Tags