15
15
*/
16
16
package com .google .maps .android .data .geojson ;
17
17
18
+ import com .google .android .gms .maps .model .Cap ;
18
19
import com .google .android .gms .maps .model .PatternItem ;
19
20
import com .google .android .gms .maps .model .PolylineOptions ;
20
21
import com .google .maps .android .data .Style ;
27
28
/**
28
29
* A class that allows for GeoJsonLineString objects to be styled and for these styles to be
29
30
* translated into a PolylineOptions object. {@see
30
- * <a href="https://developer.android .com/reference/com/google/android/gms/maps/model/PolylineOptions.html ">
31
+ * <a href="https://developers.google .com/android/ reference/com/google/android/gms/maps/model/PolylineOptions">
31
32
* PolylineOptions docs</a> for more details about the options.}
32
33
*/
33
34
public class GeoJsonLineStringStyle extends Style implements GeoJsonStyle {
@@ -43,144 +44,72 @@ public GeoJsonLineStringStyle() {
43
44
mPolylineOptions .clickable (true );
44
45
}
45
46
46
- /**
47
- * {@inheritDoc}
48
- */
49
47
@ Override
50
48
public String [] getGeometryType () {
51
49
return GEOMETRY_TYPE ;
52
50
}
53
51
54
- /**
55
- * Gets the color of the GeoJsonLineString as a 32-bit ARGB color
56
- *
57
- * @return color of the GeoJsonLineString
58
- */
59
52
public int getColor () {
60
53
return mPolylineOptions .getColor ();
61
54
}
62
55
63
- /**
64
- * Sets the color of the GeoJsonLineString as a 32-bit ARGB color
65
- *
66
- * @param color color value of the GeoJsonLineString
67
- */
68
56
public void setColor (int color ) {
69
57
mPolylineOptions .color (color );
70
58
styleChanged ();
71
59
}
72
60
73
- /**
74
- * Gets the clickability setting for this Options object
75
- *
76
- * @return true if the GeoJsonLineString is clickable; false if it is not
77
- */
78
61
public boolean isClickable () {
79
62
return mPolylineOptions .isClickable ();
80
63
}
81
64
82
- /**
83
- * Specifies whether this GeoJsonLineString is clickable
84
- *
85
- * @param clickable - new clickability setting for the GeoJsonLineString
86
- */
87
65
public void setClickable (boolean clickable ) {
88
66
mPolylineOptions .clickable (clickable );
89
67
styleChanged ();
90
68
}
91
69
92
- /**
93
- * Gets whether the GeoJsonLineString is geodesic
94
- *
95
- * @return true if GeoJsonLineString is geodesic, false otherwise
96
- */
97
70
public boolean isGeodesic () {
98
71
return mPolylineOptions .isGeodesic ();
99
72
}
100
73
101
- /**
102
- * Sets whether the GeoJsonLineString is geodesic
103
- *
104
- * @param geodesic true if GeoJsonLineString is geodesic, false otherwise
105
- */
106
74
public void setGeodesic (boolean geodesic ) {
107
75
mPolylineOptions .geodesic (geodesic );
108
76
styleChanged ();
109
77
}
110
78
111
- /**
112
- * Gets the width of the GeoJsonLineString in screen pixels
113
- *
114
- * @return width of the GeoJsonLineString
115
- */
116
79
public float getWidth () {
117
80
return mPolylineOptions .getWidth ();
118
81
}
119
82
120
- /**
121
- * Sets the width of the GeoJsonLineString in screen pixels
122
- *
123
- * @param width width value of the GeoJsonLineString
124
- */
125
83
public void setWidth (float width ) {
126
84
setLineStringWidth (width );
127
85
styleChanged ();
128
86
}
129
87
130
- /**
131
- * Gets the z index of the GeoJsonLineString
132
- *
133
- * @return z index of the GeoJsonLineString
134
- */
135
88
public float getZIndex () {
136
89
return mPolylineOptions .getZIndex ();
137
90
}
138
91
139
- /**
140
- * Sets the z index of the GeoJsonLineString
141
- *
142
- * @param zIndex z index value of the GeoJsonLineString
143
- */
144
92
public void setZIndex (float zIndex ) {
145
93
mPolylineOptions .zIndex (zIndex );
146
94
styleChanged ();
147
95
}
148
96
149
- /**
150
- * Gets whether the GeoJsonLineString is visible
151
- *
152
- * @return true if the GeoJsonLineString visible, false if not visible
153
- */
154
97
@ Override
155
98
public boolean isVisible () {
156
99
return mPolylineOptions .isVisible ();
157
100
}
158
101
159
- /**
160
- * Sets whether the GeoJsonLineString is visible
161
- *
162
- * @param visible true if the GeoJsonLineString is visible, false if not visible
163
- */
164
102
@ Override
165
103
public void setVisible (boolean visible ) {
166
104
mPolylineOptions .visible (visible );
167
105
styleChanged ();
168
106
}
169
107
170
- /**
171
- * Notifies the observers, GeoJsonFeature objects, that the style has changed. Indicates to the
172
- * GeoJsonFeature that it should check whether a redraw is needed for the feature.
173
- */
174
108
private void styleChanged () {
175
109
setChanged ();
176
110
notifyObservers ();
177
111
}
178
112
179
- /**
180
- * Gets a new PolylineOptions object containing styles for the GeoJsonLineString
181
- *
182
- * @return new PolylineOptions object
183
- */
184
113
public PolylineOptions toPolylineOptions () {
185
114
PolylineOptions polylineOptions = new PolylineOptions ();
186
115
polylineOptions .color (mPolylineOptions .getColor ());
@@ -190,6 +119,8 @@ public PolylineOptions toPolylineOptions() {
190
119
polylineOptions .width (mPolylineOptions .getWidth ());
191
120
polylineOptions .zIndex (mPolylineOptions .getZIndex ());
192
121
polylineOptions .pattern (getPattern ());
122
+ polylineOptions .startCap (getStartCap ());
123
+ polylineOptions .endCap (getEndCap ());
193
124
return polylineOptions ;
194
125
}
195
126
@@ -205,27 +136,36 @@ public String toString() {
205
136
sb .append (",\n width=" ).append (getWidth ());
206
137
sb .append (",\n z index=" ).append (getZIndex ());
207
138
sb .append (",\n pattern=" ).append (getPattern ());
139
+ sb .append (",\n startCap=" ).append (getStartCap ());
140
+ sb .append (",\n endCap=" ).append (getEndCap ());
208
141
sb .append ("\n }\n " );
209
142
return sb .toString ();
210
143
}
211
144
212
- /**
213
- * Gets the pattern of the GeoJsonLineString
214
- *
215
- * @return line style of GeoJsonLineString
216
- */
217
145
public List <PatternItem > getPattern () {
218
146
return mPolylineOptions .getPattern ();
219
147
}
220
148
221
- /**
222
- * Sets the pattern of the GeoJsonLineString
223
- *
224
- * @param pattern line style of GeoJsonLineString
225
- */
226
149
public void setPattern (List <PatternItem > pattern ) {
227
150
mPolylineOptions .pattern (pattern );
228
151
styleChanged ();
229
152
}
230
153
154
+ public void setStartCap (@ NonNull Cap cap ) {
155
+ mPolylineOptions .startCap (cap );
156
+ styleChanged ();
157
+ }
158
+
159
+ public void setEndCap (@ NonNull Cap cap ) {
160
+ mPolylineOptions .endCap (cap );
161
+ styleChanged ();
162
+ }
163
+
164
+ public Cap getStartCap () {
165
+ return mPolylineOptions .getStartCap ();
166
+ }
167
+
168
+ public Cap getEndCap () {
169
+ return mPolylineOptions .getEndCap ();
170
+ }
231
171
}
0 commit comments