source: other-projects/tipple-android/src/org/mapsforge/android/maps/OverlayMarkerItem.java@ 26523

Last change on this file since 26523 was 26523, checked in by davidb, 11 years ago

A version of Tipple with the mods Casey made for her Masters work

File size: 3.2 KB
Line 
1package org.mapsforge.android.maps;
2
3import android.graphics.Point;
4import android.graphics.drawable.Drawable;
5
6/**
7 * An OverlayMarkerItem holds all parameters of a single element on an
8 * {@link ItemizedMarkerOverlay}.
9 */
10public class OverlayMarkerItem {
11 /**
12 * Marker used to indicate the item.
13 */
14 protected Drawable marker;
15
16 /**
17 * Geographical position of the item.
18 */
19 protected final GeoPoint point;
20
21 /**
22 * Title of the item.
23 */
24 protected final String title;
25
26 /*
27 * description of the itme
28 */
29 protected final String description;
30 protected final String content;
31 /**
32 *
33 * Cached position of the item on the map.
34 */
35 Point cachedMapPosition;
36
37 /**
38 * Zoom level of the cached map position.
39 */
40 byte cachedZoomLevel;
41
42 /**
43 * Constructs a new OverlayItem.
44 *
45 * @param point
46 * the geographical position of the item.
47 */
48 public OverlayMarkerItem(GeoPoint point, String title, Drawable balloon) {
49 this.point = point;
50 this.title = title;
51 this.marker = balloon;
52 this.description = null;
53 this.cachedZoomLevel = Byte.MIN_VALUE;
54 this.content = null;
55 }
56
57 public OverlayMarkerItem(GeoPoint point, String title) {
58 this.point = point;
59 this.title = title;
60 this.description = null;
61 this.cachedZoomLevel = Byte.MIN_VALUE;
62 this.content = null;
63 }
64
65 public OverlayMarkerItem(GeoPoint point, String title, String description,
66 String content) {
67 this.point = point;
68 this.title = title;
69 this.description = description;
70 this.content = content;
71 }
72
73 protected static Drawable boundCenter(Drawable balloon) {
74 balloon.setBounds(balloon.getIntrinsicWidth() / -2,
75 balloon.getIntrinsicHeight() / -2,
76 balloon.getIntrinsicWidth() / 2,
77 balloon.getIntrinsicHeight() / 2);
78 return balloon;
79 }
80
81 /**
82 * Sets the bounds of the given drawable so that (0,0) is the center of the
83 * bounding box.
84 *
85 * @param balloon
86 * the drawable whose bounds should be set.
87 * @return the given drawable.
88 */
89 protected static Drawable boundCenterBottom(Drawable balloon) {
90 balloon.setBounds(balloon.getIntrinsicWidth() / -2,
91 -balloon.getIntrinsicHeight(), balloon.getIntrinsicWidth() / 2,
92 0);
93 return balloon;
94 }
95
96 /**
97 * Returns the marker used to indicate the item (may be null).
98 *
99 * @return the marker used to indicate the item.
100 */
101 public Drawable getMarker() {
102 return this.marker;
103 }
104
105 /**
106 * Returns the position of the item.
107 *
108 * @return the position of the item.
109 */
110 public GeoPoint getPoint() {
111 return this.point;
112 }
113
114 /**
115 * Returns the title of the item.
116 *
117 * @return the title of the item.
118 */
119 public String getTitle() {
120 return this.title;
121 }
122
123 /**
124 * Return the description of the item
125 */
126 public String getDescription() {
127 return this.description;
128 }
129
130 public String getContent() {
131 return this.content;
132 }
133
134 /**
135 * Sets the marker that is drawn on the map for this item. If the item
136 * marker is null, the default marker will be drawn instead.
137 *
138 * @param marker
139 * the marker that is drawn on the map for this item.
140 */
141 public void setMarker(Drawable marker) {
142 this.marker = boundCenterBottom(marker);
143 }
144
145}
Note: See TracBrowser for help on using the repository browser.