summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/line/Line.java
blob: d7c62dfe92942053e2b8411f9396d749824cd354 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.

package com.mapbox.mapboxsdk.annotations.line;

import android.support.annotation.UiThread;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mapbox.geojson.*;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.style.layers.Property;

import java.util.ArrayList;
import java.util.List;

@UiThread
public class Line {

  public static final String ID_KEY = "id-line";
  private final LineManager lineManager;
  private final JsonObject jsonObject = new JsonObject();
  private Geometry geometry;

  /**
   * Create a line.
   *
   * @param manager the line manager created and managing the line
   * @param id            the id of the line
   */
  Line(LineManager manager, long id) {
    this.lineManager = manager;
    this.jsonObject.addProperty(ID_KEY, id);
  }

  /**
   * Get the line geometry.
   *
   * @return the line geometry
   */
  Geometry getGeometry() {
    if (geometry == null) {
      throw new IllegalStateException();
    }
    return geometry;
  }

  /**
   * Get the line feature properties.
   *
   * @return the line feature properties
   */
  JsonObject getFeature() {
    return jsonObject;
  }

  /**
   * Get the line id.
   *
   * @return the line id
   */
  public long getId() {
    return jsonObject.get(ID_KEY).getAsLong();
  }

  /**
   * Set a list of LatLng for the line, which represents the locations of the line on the map
   *
   * @param latLngs a list of the locations of the line in a longitude and latitude pairs
   */
  public void setLatLngs(List<LatLng> latLngs) {
    List<Point>points = new ArrayList<>();
    for (LatLng latLng : latLngs) {
      points.add(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
    }
    geometry = LineString.fromLngLats(points);
    lineManager.updateSource();
  }

  // Property accessors
  /**
   * Get the LineJoin property
   *
   * @return property wrapper value around String
   */
  @Property.LINE_JOIN
  public String getLineJoin() {
    return jsonObject.get("line-join").getAsString();
  }

  /**
   * Set the LineJoin property
   *
   * @param value constant property value for String
   */
  public void setLineJoin(@Property.LINE_JOIN String value) {
    jsonObject.addProperty("line-join", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineOpacity property
   *
   * @return property wrapper value around Float
   */
  
  public Float getLineOpacity() {
    return jsonObject.get("line-opacity").getAsFloat();
  }

  /**
   * Set the LineOpacity property
   *
   * @param value constant property value for Float
   */
  public void setLineOpacity( Float value) {
    jsonObject.addProperty("line-opacity", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineColor property
   *
   * @return property wrapper value around String
   */
  
  public String getLineColor() {
    return jsonObject.get("line-color").getAsString();
  }

  /**
   * Set the LineColor property
   *
   * @param value constant property value for String
   */
  public void setLineColor( String value) {
    jsonObject.addProperty("line-color", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineWidth property
   *
   * @return property wrapper value around Float
   */
  
  public Float getLineWidth() {
    return jsonObject.get("line-width").getAsFloat();
  }

  /**
   * Set the LineWidth property
   *
   * @param value constant property value for Float
   */
  public void setLineWidth( Float value) {
    jsonObject.addProperty("line-width", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineGapWidth property
   *
   * @return property wrapper value around Float
   */
  
  public Float getLineGapWidth() {
    return jsonObject.get("line-gap-width").getAsFloat();
  }

  /**
   * Set the LineGapWidth property
   *
   * @param value constant property value for Float
   */
  public void setLineGapWidth( Float value) {
    jsonObject.addProperty("line-gap-width", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineOffset property
   *
   * @return property wrapper value around Float
   */
  
  public Float getLineOffset() {
    return jsonObject.get("line-offset").getAsFloat();
  }

  /**
   * Set the LineOffset property
   *
   * @param value constant property value for Float
   */
  public void setLineOffset( Float value) {
    jsonObject.addProperty("line-offset", value);
    lineManager.updateSource();
  }

  /**
   * Get the LineBlur property
   *
   * @return property wrapper value around Float
   */
  
  public Float getLineBlur() {
    return jsonObject.get("line-blur").getAsFloat();
  }

  /**
   * Set the LineBlur property
   *
   * @param value constant property value for Float
   */
  public void setLineBlur( Float value) {
    jsonObject.addProperty("line-blur", value);
    lineManager.updateSource();
  }

  /**
   * Get the LinePattern property
   *
   * @return property wrapper value around String
   */
  
  public String getLinePattern() {
    return jsonObject.get("line-pattern").getAsString();
  }

  /**
   * Set the LinePattern property
   *
   * @param value constant property value for String
   */
  public void setLinePattern( String value) {
    jsonObject.addProperty("line-pattern", value);
    lineManager.updateSource();
  }

}