summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/symbol/Symbol.java
blob: f4155e1b07f83e10a314291acd8b9409ed8b79e4 (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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.

package com.mapbox.mapboxsdk.symbol;

import android.support.annotation.UiThread;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mapbox.geojson.Geometry;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;

@UiThread
public class Symbol {

  public static final String ID_KEY = "id-symbol";

  private final SymbolManager symbolManager;
  private final JsonObject jsonObject = new JsonObject();
  private Geometry geometry;

  /**
   * Create a symbol.
   *
   * @param symbolManager the symbol manager created and managing the symbol
   * @param id            the id of the symbol
   */
  Symbol(SymbolManager symbolManager, long id) {
    this.symbolManager = symbolManager;
    this.jsonObject.addProperty(ID_KEY, id);
  }

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

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

  /**
   * Set the LatLng of the symbol, which represents the location of the symbol on the map
   *
   * @param latLng the location of the symbol in a longitude and latitude pair
   */
  public void setLatLng(LatLng latLng) {
    geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
    symbolManager.updateSource();
  }

  // Property accessors
  /**
   * Get the IconSize property
   *
   * @return property wrapper value around Float
   */
  public Float getIconSize() {
    return jsonObject.get("icon-size").getAsFloat();
  }

  /**
   * Set the IconSize property
   *
   * @return property wrapper value around Float
   */
  public void setIconSize(Float value) {
    jsonObject.addProperty("icon-size", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconImage property
   *
   * @return property wrapper value around String
   */
  public String getIconImage() {
    return jsonObject.get("icon-image").getAsString();
  }

  /**
   * Set the IconImage property
   *
   * @return property wrapper value around String
   */
  public void setIconImage(String value) {
    jsonObject.addProperty("icon-image", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconRotate property
   *
   * @return property wrapper value around Float
   */
  public Float getIconRotate() {
    return jsonObject.get("icon-rotate").getAsFloat();
  }

  /**
   * Set the IconRotate property
   *
   * @return property wrapper value around Float
   */
  public void setIconRotate(Float value) {
    jsonObject.addProperty("icon-rotate", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconOffset property
   *
   * @return property wrapper value around Float[]
   */
  public Float[] getIconOffset() {
    JsonArray jsonArray = jsonObject.getAsJsonArray("icon-offset");
    Float[] value = new Float[jsonArray.size()];
    for (int i = 0; i < jsonArray.size(); i++) {
      value[i] = jsonArray.get(i).getAsFloat();
    }
    return value;
  }

  /**
   * Set the IconOffset property
   *
   * @return property wrapper value around Float[]
   */
  public void setIconOffset(Float[] value) {
    JsonArray jsonArray = new JsonArray();
    for (Float element : value) {
      jsonArray.add(element);
    }
    jsonObject.add("icon-offset", jsonArray);
    symbolManager.updateSource();
  }

  /**
   * Get the IconAnchor property
   *
   * @return property wrapper value around String
   */
  public String getIconAnchor() {
    return jsonObject.get("icon-anchor").getAsString();
  }

  /**
   * Set the IconAnchor property
   *
   * @return property wrapper value around String
   */
  public void setIconAnchor(String value) {
    jsonObject.addProperty("icon-anchor", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextField property
   *
   * @return property wrapper value around String
   */
  public String getTextField() {
    return jsonObject.get("text-field").getAsString();
  }

  /**
   * Set the TextField property
   *
   * @return property wrapper value around String
   */
  public void setTextField(String value) {
    jsonObject.addProperty("text-field", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextFont property
   *
   * @return property wrapper value around String[]
   */
  public String[] getTextFont() {
    JsonArray jsonArray = jsonObject.getAsJsonArray("text-font");
    String[] value = new String[jsonArray.size()];
    for (int i = 0; i < jsonArray.size(); i++) {
      value[i] = jsonArray.get(i).getAsString();
    }
    return value;
  }

  /**
   * Set the TextFont property
   *
   * @return property wrapper value around String[]
   */
  public void setTextFont(String[] value) {
    JsonArray jsonArray = new JsonArray();
    for (String element : value) {
      jsonArray.add(element);
    }
    jsonObject.add("text-font", jsonArray);
    symbolManager.updateSource();
  }

  /**
   * Get the TextSize property
   *
   * @return property wrapper value around Float
   */
  public Float getTextSize() {
    return jsonObject.get("text-size").getAsFloat();
  }

  /**
   * Set the TextSize property
   *
   * @return property wrapper value around Float
   */
  public void setTextSize(Float value) {
    jsonObject.addProperty("text-size", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextMaxWidth property
   *
   * @return property wrapper value around Float
   */
  public Float getTextMaxWidth() {
    return jsonObject.get("text-max-width").getAsFloat();
  }

  /**
   * Set the TextMaxWidth property
   *
   * @return property wrapper value around Float
   */
  public void setTextMaxWidth(Float value) {
    jsonObject.addProperty("text-max-width", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextLetterSpacing property
   *
   * @return property wrapper value around Float
   */
  public Float getTextLetterSpacing() {
    return jsonObject.get("text-letter-spacing").getAsFloat();
  }

  /**
   * Set the TextLetterSpacing property
   *
   * @return property wrapper value around Float
   */
  public void setTextLetterSpacing(Float value) {
    jsonObject.addProperty("text-letter-spacing", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextJustify property
   *
   * @return property wrapper value around String
   */
  public String getTextJustify() {
    return jsonObject.get("text-justify").getAsString();
  }

  /**
   * Set the TextJustify property
   *
   * @return property wrapper value around String
   */
  public void setTextJustify(String value) {
    jsonObject.addProperty("text-justify", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextAnchor property
   *
   * @return property wrapper value around String
   */
  public String getTextAnchor() {
    return jsonObject.get("text-anchor").getAsString();
  }

  /**
   * Set the TextAnchor property
   *
   * @return property wrapper value around String
   */
  public void setTextAnchor(String value) {
    jsonObject.addProperty("text-anchor", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextRotate property
   *
   * @return property wrapper value around Float
   */
  public Float getTextRotate() {
    return jsonObject.get("text-rotate").getAsFloat();
  }

  /**
   * Set the TextRotate property
   *
   * @return property wrapper value around Float
   */
  public void setTextRotate(Float value) {
    jsonObject.addProperty("text-rotate", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextTransform property
   *
   * @return property wrapper value around String
   */
  public String getTextTransform() {
    return jsonObject.get("text-transform").getAsString();
  }

  /**
   * Set the TextTransform property
   *
   * @return property wrapper value around String
   */
  public void setTextTransform(String value) {
    jsonObject.addProperty("text-transform", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextOffset property
   *
   * @return property wrapper value around Float[]
   */
  public Float[] getTextOffset() {
    JsonArray jsonArray = jsonObject.getAsJsonArray("text-offset");
    Float[] value = new Float[jsonArray.size()];
    for (int i = 0; i < jsonArray.size(); i++) {
      value[i] = jsonArray.get(i).getAsFloat();
    }
    return value;
  }

  /**
   * Set the TextOffset property
   *
   * @return property wrapper value around Float[]
   */
  public void setTextOffset(Float[] value) {
    JsonArray jsonArray = new JsonArray();
    for (Float element : value) {
      jsonArray.add(element);
    }
    jsonObject.add("text-offset", jsonArray);
    symbolManager.updateSource();
  }

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

  /**
   * Set the IconOpacity property
   *
   * @return property wrapper value around Float
   */
  public void setIconOpacity(Float value) {
    jsonObject.addProperty("icon-opacity", value);
    symbolManager.updateSource();
  }

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

  /**
   * Set the IconColor property
   *
   * @return property wrapper value around String
   */
  public void setIconColor(String value) {
    jsonObject.addProperty("icon-color", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconHaloColor property
   *
   * @return property wrapper value around String
   */
  public String getIconHaloColor() {
    return jsonObject.get("icon-halo-color").getAsString();
  }

  /**
   * Set the IconHaloColor property
   *
   * @return property wrapper value around String
   */
  public void setIconHaloColor(String value) {
    jsonObject.addProperty("icon-halo-color", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconHaloWidth property
   *
   * @return property wrapper value around Float
   */
  public Float getIconHaloWidth() {
    return jsonObject.get("icon-halo-width").getAsFloat();
  }

  /**
   * Set the IconHaloWidth property
   *
   * @return property wrapper value around Float
   */
  public void setIconHaloWidth(Float value) {
    jsonObject.addProperty("icon-halo-width", value);
    symbolManager.updateSource();
  }

  /**
   * Get the IconHaloBlur property
   *
   * @return property wrapper value around Float
   */
  public Float getIconHaloBlur() {
    return jsonObject.get("icon-halo-blur").getAsFloat();
  }

  /**
   * Set the IconHaloBlur property
   *
   * @return property wrapper value around Float
   */
  public void setIconHaloBlur(Float value) {
    jsonObject.addProperty("icon-halo-blur", value);
    symbolManager.updateSource();
  }

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

  /**
   * Set the TextOpacity property
   *
   * @return property wrapper value around Float
   */
  public void setTextOpacity(Float value) {
    jsonObject.addProperty("text-opacity", value);
    symbolManager.updateSource();
  }

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

  /**
   * Set the TextColor property
   *
   * @return property wrapper value around String
   */
  public void setTextColor(String value) {
    jsonObject.addProperty("text-color", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextHaloColor property
   *
   * @return property wrapper value around String
   */
  public String getTextHaloColor() {
    return jsonObject.get("text-halo-color").getAsString();
  }

  /**
   * Set the TextHaloColor property
   *
   * @return property wrapper value around String
   */
  public void setTextHaloColor(String value) {
    jsonObject.addProperty("text-halo-color", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextHaloWidth property
   *
   * @return property wrapper value around Float
   */
  public Float getTextHaloWidth() {
    return jsonObject.get("text-halo-width").getAsFloat();
  }

  /**
   * Set the TextHaloWidth property
   *
   * @return property wrapper value around Float
   */
  public void setTextHaloWidth(Float value) {
    jsonObject.addProperty("text-halo-width", value);
    symbolManager.updateSource();
  }

  /**
   * Get the TextHaloBlur property
   *
   * @return property wrapper value around Float
   */
  public Float getTextHaloBlur() {
    return jsonObject.get("text-halo-blur").getAsFloat();
  }

  /**
   * Set the TextHaloBlur property
   *
   * @return property wrapper value around Float
   */
  public void setTextHaloBlur(Float value) {
    jsonObject.addProperty("text-halo-blur", value);
    symbolManager.updateSource();
  }

}