KickJava   Java API By Example, From Geeks To Geeks.

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


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  * GoogleMapCircleTag
11  *
12  * This class represents a <googlemaps:circle> tag. Developers should not
13  * override this class.
14  *
15  * @author Tom Cole
16  * @version 0.40
17  */

18 public class GoogleMapCircleTag extends TagSupport JavaDoc implements Serializable JavaDoc, GoogleMapEventListener {
19     
20     String JavaDoc id = null;
21     String JavaDoc point = null;
22     double radius = 1.00d;
23     String JavaDoc color = "#ff0000";
24     int weight = 2;
25     float opacity = 0.50f;
26     Vector JavaDoc events = null;
27     /**
28      * Overrides doStartTag() in TagSupport. Developers should not override this method.
29      * If they do, they must call super.doStartTag() to ensure the tag get added to the
30      * tree properly.
31      */

32     public int doStartTag() {
33         Tag JavaDoc tag = this;
34         while (tag.getParent() != null) {
35             if (tag.getParent() instanceof GoogleMapTag) {
36                 ((GoogleMapTag) tag.getParent()).addCircle(this);
37                 return SKIP_BODY;
38             }
39             tag = tag.getParent();
40         }
41         return SKIP_BODY;
42     }
43     /**
44      * Sets the color used to draw this overlay. Default is #ff0000.
45      *
46      * @param color The color code in hexadecimal format.
47      */

48     public void setColor(String JavaDoc color) {
49         this.color = color;
50     }
51     /**
52      * Sets the 0-1 based opacity of the circle. 0 is invisible, 1 is fully opaque.
53      *
54      * @param opacity A float from 0-1.
55      */

56     public void setOpacity(float opacity) {
57         this.opacity = opacity;
58     }
59     /**
60      * Sets the radius of the circle (in miles) from the centerpoint.
61      *
62      * @param radius A double indicating miles.
63      */

64     public void setRadius(double radius) {
65         this.radius = radius;
66     }
67     /**
68      * Returns the current radius set for this circle.
69      *
70      * @returns A double indicating miles of radius.
71      */

72     public double getRadius() {
73         return radius;
74     }
75     /**
76      * Sets the weight (width) of the circle line in pixels.
77      *
78      * @param weight An int specifying line width in pixels.
79      */

80     public void setWeight(int weight) {
81         this.weight = weight;
82     }
83     /**
84      * Returns the point id that is used as the centerpoint.
85      *
86      * @return A String representing the centerpoint's id.
87      */

88     public String JavaDoc getPoint() {
89         return point;
90     }
91     /**
92      * Sets the id of the point to be used as the centerpoint for the circle.
93      *
94      * @param point A String representing the id of the centerpoint.
95      */

96     public void setPoint(String JavaDoc point) {
97         this.point = point;
98     }
99     /**
100      * Returns the color used to draw this circle, in hexadecimal format.
101      *
102      * @return A hexadecimal String representing a color.
103      */

104     public String JavaDoc getColor() {
105         return color;
106     }
107     /**
108      * Returns the current opacity level (0-1) of the circle line.
109      *
110      * @return A float indicating opacity level.
111      */

112     public float getOpacity() {
113         return opacity;
114     }
115     /**
116      * Returns the current width (in pixels) if the circle line.
117      *
118      * @return An int representing line width (in pixels).
119      */

120     public int getWeight() {
121         return weight;
122     }
123     /**
124      * Returns the id of this circle.
125      *
126      * @return The circle's id.
127      */

128     public String JavaDoc getId() {
129         return id;
130     }
131     /**
132      * Sets the id for this circle.
133      *
134      * @param id The circle's unique id.
135      */

136     public void setId(String JavaDoc id) {
137         this.id = id;
138     }
139     /**
140      * Adds an event listener to this overlay.
141      *
142      * @param event A GoogleMapEventTag
143      */

144     public void addEvent(GoogleMapEventTag event) {
145         if (events == null)
146             events = new Vector JavaDoc();
147         events.add(event);
148     }
149     /**
150      * Returns the list of currently registered event listeners
151      * for this overlay.
152      *
153      * @return A Vector of GoogleMapEventTags
154      */

155     public Vector JavaDoc getEvents() {
156         return events;
157     }
158 }
159
Popular Tags