-
Notifications
You must be signed in to change notification settings - Fork 119
/
SymbolOptions.java
960 lines (886 loc) · 29.1 KB
/
SymbolOptions.java
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
// This file is generated.
package com.mapbox.mapboxsdk.plugins.annotation;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.gson.*;
import com.mapbox.geojson.Geometry;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.geojson.*;
import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.ArrayList;
import java.util.List;
import static com.mapbox.mapboxsdk.plugins.annotation.ConvertUtils.convertArray;
import static com.mapbox.mapboxsdk.plugins.annotation.ConvertUtils.toFloatArray;
import static com.mapbox.mapboxsdk.plugins.annotation.ConvertUtils.toStringArray;
/**
* Builder class from which a symbol is created.
*/
public class SymbolOptions extends Options<Symbol> {
private boolean isDraggable;
private JsonElement data;
private Point geometry;
private Float symbolSortKey;
private Float iconSize;
private String iconImage;
private Float iconRotate;
private Float[] iconOffset;
private String iconAnchor;
private String textField;
private String[] textFont;
private Float textSize;
private Float textMaxWidth;
private Float textLetterSpacing;
private String textJustify;
private Float textRadialOffset;
private String textAnchor;
private Float textRotate;
private String textTransform;
private Float[] textOffset;
private Float iconOpacity;
private String iconColor;
private String iconHaloColor;
private Float iconHaloWidth;
private Float iconHaloBlur;
private Float textOpacity;
private String textColor;
private String textHaloColor;
private Float textHaloWidth;
private Float textHaloBlur;
static final String PROPERTY_SYMBOL_SORT_KEY = "symbol-sort-key";
static final String PROPERTY_ICON_SIZE = "icon-size";
static final String PROPERTY_ICON_IMAGE = "icon-image";
static final String PROPERTY_ICON_ROTATE = "icon-rotate";
static final String PROPERTY_ICON_OFFSET = "icon-offset";
static final String PROPERTY_ICON_ANCHOR = "icon-anchor";
static final String PROPERTY_TEXT_FIELD = "text-field";
static final String PROPERTY_TEXT_FONT = "text-font";
static final String PROPERTY_TEXT_SIZE = "text-size";
static final String PROPERTY_TEXT_MAX_WIDTH = "text-max-width";
static final String PROPERTY_TEXT_LETTER_SPACING = "text-letter-spacing";
static final String PROPERTY_TEXT_JUSTIFY = "text-justify";
static final String PROPERTY_TEXT_RADIAL_OFFSET = "text-radial-offset";
static final String PROPERTY_TEXT_ANCHOR = "text-anchor";
static final String PROPERTY_TEXT_ROTATE = "text-rotate";
static final String PROPERTY_TEXT_TRANSFORM = "text-transform";
static final String PROPERTY_TEXT_OFFSET = "text-offset";
static final String PROPERTY_ICON_OPACITY = "icon-opacity";
static final String PROPERTY_ICON_COLOR = "icon-color";
static final String PROPERTY_ICON_HALO_COLOR = "icon-halo-color";
static final String PROPERTY_ICON_HALO_WIDTH = "icon-halo-width";
static final String PROPERTY_ICON_HALO_BLUR = "icon-halo-blur";
static final String PROPERTY_TEXT_OPACITY = "text-opacity";
static final String PROPERTY_TEXT_COLOR = "text-color";
static final String PROPERTY_TEXT_HALO_COLOR = "text-halo-color";
static final String PROPERTY_TEXT_HALO_WIDTH = "text-halo-width";
static final String PROPERTY_TEXT_HALO_BLUR = "text-halo-blur";
private static final String PROPERTY_IS_DRAGGABLE = "is-draggable";
/**
* Set symbol-sort-key to initialise the symbol with.
* <p>
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key when they overlap. Features with a lower sort key will have priority over other features when doing placement.
* </p>
* @param symbolSortKey the symbol-sort-key value
* @return this
*/
public SymbolOptions withSymbolSortKey(Float symbolSortKey) {
this.symbolSortKey = symbolSortKey;
return this;
}
/**
* Get the current configured symbol-sort-key for the symbol
* <p>
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key when they overlap. Features with a lower sort key will have priority over other features when doing placement.
* </p>
* @return symbolSortKey value
*/
public Float getSymbolSortKey() {
return symbolSortKey;
}
/**
* Set icon-size to initialise the symbol with.
* <p>
* Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by {@link PropertyFactory#iconSize}. 1 is the original size; 3 triples the size of the image.
* </p>
* @param iconSize the icon-size value
* @return this
*/
public SymbolOptions withIconSize(Float iconSize) {
this.iconSize = iconSize;
return this;
}
/**
* Get the current configured icon-size for the symbol
* <p>
* Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by {@link PropertyFactory#iconSize}. 1 is the original size; 3 triples the size of the image.
* </p>
* @return iconSize value
*/
public Float getIconSize() {
return iconSize;
}
/**
* Set icon-image to initialise the symbol with.
* <p>
* Name of image in sprite to use for drawing an image background.
* </p>
* @param iconImage the icon-image value
* @return this
*/
public SymbolOptions withIconImage(String iconImage) {
this.iconImage = iconImage;
return this;
}
/**
* Get the current configured icon-image for the symbol
* <p>
* Name of image in sprite to use for drawing an image background.
* </p>
* @return iconImage value
*/
public String getIconImage() {
return iconImage;
}
/**
* Set icon-rotate to initialise the symbol with.
* <p>
* Rotates the icon clockwise.
* </p>
* @param iconRotate the icon-rotate value
* @return this
*/
public SymbolOptions withIconRotate(Float iconRotate) {
this.iconRotate = iconRotate;
return this;
}
/**
* Get the current configured icon-rotate for the symbol
* <p>
* Rotates the icon clockwise.
* </p>
* @return iconRotate value
*/
public Float getIconRotate() {
return iconRotate;
}
/**
* Set icon-offset to initialise the symbol with.
* <p>
* Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of {@link PropertyFactory#iconSize} to obtain the final offset in density-independent pixels. When combined with {@link PropertyFactory#iconRotate} the offset will be as if the rotated direction was up.
* </p>
* @param iconOffset the icon-offset value
* @return this
*/
public SymbolOptions withIconOffset(Float[] iconOffset) {
this.iconOffset = iconOffset;
return this;
}
/**
* Get the current configured icon-offset for the symbol
* <p>
* Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of {@link PropertyFactory#iconSize} to obtain the final offset in density-independent pixels. When combined with {@link PropertyFactory#iconRotate} the offset will be as if the rotated direction was up.
* </p>
* @return iconOffset value
*/
public Float[] getIconOffset() {
return iconOffset;
}
/**
* Set icon-anchor to initialise the symbol with.
* <p>
* Part of the icon placed closest to the anchor.
* </p>
* @param iconAnchor the icon-anchor value
* @return this
*/
public SymbolOptions withIconAnchor(@Property.ICON_ANCHOR String iconAnchor) {
this.iconAnchor = iconAnchor;
return this;
}
/**
* Get the current configured icon-anchor for the symbol
* <p>
* Part of the icon placed closest to the anchor.
* </p>
* @return iconAnchor value
*/
public String getIconAnchor() {
return iconAnchor;
}
/**
* Set text-field to initialise the symbol with.
* <p>
* Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.
* </p>
* @param textField the text-field value
* @return this
*/
public SymbolOptions withTextField(String textField) {
this.textField = textField;
return this;
}
/**
* Get the current configured text-field for the symbol
* <p>
* Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.
* </p>
* @return textField value
*/
public String getTextField() {
return textField;
}
/**
* Set text-font to initialise the symbol with.
* <p>
* Font stack to use for displaying text.
* </p>
* @param textFont the text-font value
* @return this
*/
public SymbolOptions withTextFont(String[] textFont) {
this.textFont = textFont;
return this;
}
/**
* Get the current configured text-font for the symbol
* <p>
* Font stack to use for displaying text.
* </p>
* @return textFont value
*/
public String[] getTextFont() {
return textFont;
}
/**
* Set text-size to initialise the symbol with.
* <p>
* Font size.
* </p>
* @param textSize the text-size value
* @return this
*/
public SymbolOptions withTextSize(Float textSize) {
this.textSize = textSize;
return this;
}
/**
* Get the current configured text-size for the symbol
* <p>
* Font size.
* </p>
* @return textSize value
*/
public Float getTextSize() {
return textSize;
}
/**
* Set text-max-width to initialise the symbol with.
* <p>
* The maximum line width for text wrapping.
* </p>
* @param textMaxWidth the text-max-width value
* @return this
*/
public SymbolOptions withTextMaxWidth(Float textMaxWidth) {
this.textMaxWidth = textMaxWidth;
return this;
}
/**
* Get the current configured text-max-width for the symbol
* <p>
* The maximum line width for text wrapping.
* </p>
* @return textMaxWidth value
*/
public Float getTextMaxWidth() {
return textMaxWidth;
}
/**
* Set text-letter-spacing to initialise the symbol with.
* <p>
* Text tracking amount.
* </p>
* @param textLetterSpacing the text-letter-spacing value
* @return this
*/
public SymbolOptions withTextLetterSpacing(Float textLetterSpacing) {
this.textLetterSpacing = textLetterSpacing;
return this;
}
/**
* Get the current configured text-letter-spacing for the symbol
* <p>
* Text tracking amount.
* </p>
* @return textLetterSpacing value
*/
public Float getTextLetterSpacing() {
return textLetterSpacing;
}
/**
* Set text-justify to initialise the symbol with.
* <p>
* Text justification options.
* </p>
* @param textJustify the text-justify value
* @return this
*/
public SymbolOptions withTextJustify(@Property.TEXT_JUSTIFY String textJustify) {
this.textJustify = textJustify;
return this;
}
/**
* Get the current configured text-justify for the symbol
* <p>
* Text justification options.
* </p>
* @return textJustify value
*/
public String getTextJustify() {
return textJustify;
}
/**
* Set text-radial-offset to initialise the symbol with.
* <p>
* Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}.
* </p>
* @param textRadialOffset the text-radial-offset value
* @return this
*/
public SymbolOptions withTextRadialOffset(Float textRadialOffset) {
this.textRadialOffset = textRadialOffset;
return this;
}
/**
* Get the current configured text-radial-offset for the symbol
* <p>
* Radial offset of text, in the direction of the symbol's anchor. Useful in combination with {@link PropertyFactory#textVariableAnchor}, which doesn't support the two-dimensional {@link PropertyFactory#textOffset}.
* </p>
* @return textRadialOffset value
*/
public Float getTextRadialOffset() {
return textRadialOffset;
}
/**
* Set text-anchor to initialise the symbol with.
* <p>
* Part of the text placed closest to the anchor.
* </p>
* @param textAnchor the text-anchor value
* @return this
*/
public SymbolOptions withTextAnchor(@Property.TEXT_ANCHOR String textAnchor) {
this.textAnchor = textAnchor;
return this;
}
/**
* Get the current configured text-anchor for the symbol
* <p>
* Part of the text placed closest to the anchor.
* </p>
* @return textAnchor value
*/
public String getTextAnchor() {
return textAnchor;
}
/**
* Set text-rotate to initialise the symbol with.
* <p>
* Rotates the text clockwise.
* </p>
* @param textRotate the text-rotate value
* @return this
*/
public SymbolOptions withTextRotate(Float textRotate) {
this.textRotate = textRotate;
return this;
}
/**
* Get the current configured text-rotate for the symbol
* <p>
* Rotates the text clockwise.
* </p>
* @return textRotate value
*/
public Float getTextRotate() {
return textRotate;
}
/**
* Set text-transform to initialise the symbol with.
* <p>
* Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property.
* </p>
* @param textTransform the text-transform value
* @return this
*/
public SymbolOptions withTextTransform(@Property.TEXT_TRANSFORM String textTransform) {
this.textTransform = textTransform;
return this;
}
/**
* Get the current configured text-transform for the symbol
* <p>
* Specifies how to capitalize text, similar to the CSS {@link PropertyFactory#textTransform} property.
* </p>
* @return textTransform value
*/
public String getTextTransform() {
return textTransform;
}
/**
* Set text-offset to initialise the symbol with.
* <p>
* Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up.
* </p>
* @param textOffset the text-offset value
* @return this
*/
public SymbolOptions withTextOffset(Float[] textOffset) {
this.textOffset = textOffset;
return this;
}
/**
* Get the current configured text-offset for the symbol
* <p>
* Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up.
* </p>
* @return textOffset value
*/
public Float[] getTextOffset() {
return textOffset;
}
/**
* Set icon-opacity to initialise the symbol with.
* <p>
* The opacity at which the icon will be drawn.
* </p>
* @param iconOpacity the icon-opacity value
* @return this
*/
public SymbolOptions withIconOpacity(Float iconOpacity) {
this.iconOpacity = iconOpacity;
return this;
}
/**
* Get the current configured icon-opacity for the symbol
* <p>
* The opacity at which the icon will be drawn.
* </p>
* @return iconOpacity value
*/
public Float getIconOpacity() {
return iconOpacity;
}
/**
* Set icon-color to initialise the symbol with.
* <p>
* The color of the icon. This can only be used with sdf icons.
* </p>
* @param iconColor the icon-color value
* @return this
*/
public SymbolOptions withIconColor(String iconColor) {
this.iconColor = iconColor;
return this;
}
/**
* Get the current configured icon-color for the symbol
* <p>
* The color of the icon. This can only be used with sdf icons.
* </p>
* @return iconColor value
*/
public String getIconColor() {
return iconColor;
}
/**
* Set icon-halo-color to initialise the symbol with.
* <p>
* The color of the icon's halo. Icon halos can only be used with SDF icons.
* </p>
* @param iconHaloColor the icon-halo-color value
* @return this
*/
public SymbolOptions withIconHaloColor(String iconHaloColor) {
this.iconHaloColor = iconHaloColor;
return this;
}
/**
* Get the current configured icon-halo-color for the symbol
* <p>
* The color of the icon's halo. Icon halos can only be used with SDF icons.
* </p>
* @return iconHaloColor value
*/
public String getIconHaloColor() {
return iconHaloColor;
}
/**
* Set icon-halo-width to initialise the symbol with.
* <p>
* Distance of halo to the icon outline.
* </p>
* @param iconHaloWidth the icon-halo-width value
* @return this
*/
public SymbolOptions withIconHaloWidth(Float iconHaloWidth) {
this.iconHaloWidth = iconHaloWidth;
return this;
}
/**
* Get the current configured icon-halo-width for the symbol
* <p>
* Distance of halo to the icon outline.
* </p>
* @return iconHaloWidth value
*/
public Float getIconHaloWidth() {
return iconHaloWidth;
}
/**
* Set icon-halo-blur to initialise the symbol with.
* <p>
* Fade out the halo towards the outside.
* </p>
* @param iconHaloBlur the icon-halo-blur value
* @return this
*/
public SymbolOptions withIconHaloBlur(Float iconHaloBlur) {
this.iconHaloBlur = iconHaloBlur;
return this;
}
/**
* Get the current configured icon-halo-blur for the symbol
* <p>
* Fade out the halo towards the outside.
* </p>
* @return iconHaloBlur value
*/
public Float getIconHaloBlur() {
return iconHaloBlur;
}
/**
* Set text-opacity to initialise the symbol with.
* <p>
* The opacity at which the text will be drawn.
* </p>
* @param textOpacity the text-opacity value
* @return this
*/
public SymbolOptions withTextOpacity(Float textOpacity) {
this.textOpacity = textOpacity;
return this;
}
/**
* Get the current configured text-opacity for the symbol
* <p>
* The opacity at which the text will be drawn.
* </p>
* @return textOpacity value
*/
public Float getTextOpacity() {
return textOpacity;
}
/**
* Set text-color to initialise the symbol with.
* <p>
* The color with which the text will be drawn.
* </p>
* @param textColor the text-color value
* @return this
*/
public SymbolOptions withTextColor(String textColor) {
this.textColor = textColor;
return this;
}
/**
* Get the current configured text-color for the symbol
* <p>
* The color with which the text will be drawn.
* </p>
* @return textColor value
*/
public String getTextColor() {
return textColor;
}
/**
* Set text-halo-color to initialise the symbol with.
* <p>
* The color of the text's halo, which helps it stand out from backgrounds.
* </p>
* @param textHaloColor the text-halo-color value
* @return this
*/
public SymbolOptions withTextHaloColor(String textHaloColor) {
this.textHaloColor = textHaloColor;
return this;
}
/**
* Get the current configured text-halo-color for the symbol
* <p>
* The color of the text's halo, which helps it stand out from backgrounds.
* </p>
* @return textHaloColor value
*/
public String getTextHaloColor() {
return textHaloColor;
}
/**
* Set text-halo-width to initialise the symbol with.
* <p>
* Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
* </p>
* @param textHaloWidth the text-halo-width value
* @return this
*/
public SymbolOptions withTextHaloWidth(Float textHaloWidth) {
this.textHaloWidth = textHaloWidth;
return this;
}
/**
* Get the current configured text-halo-width for the symbol
* <p>
* Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.
* </p>
* @return textHaloWidth value
*/
public Float getTextHaloWidth() {
return textHaloWidth;
}
/**
* Set text-halo-blur to initialise the symbol with.
* <p>
* The halo's fadeout distance towards the outside.
* </p>
* @param textHaloBlur the text-halo-blur value
* @return this
*/
public SymbolOptions withTextHaloBlur(Float textHaloBlur) {
this.textHaloBlur = textHaloBlur;
return this;
}
/**
* Get the current configured text-halo-blur for the symbol
* <p>
* The halo's fadeout distance towards the outside.
* </p>
* @return textHaloBlur value
*/
public Float getTextHaloBlur() {
return textHaloBlur;
}
/**
* 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
* @return this
*/
public SymbolOptions withLatLng(LatLng latLng) {
geometry = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
return this;
}
/**
* Get the LatLng of the symbol, which represents the location of the symbol on the map
*
* @return the location of the symbol in a longitude and latitude pair
*/
public LatLng getLatLng() {
if (geometry == null) {
return null;
}
return new LatLng(geometry.latitude(), geometry.longitude());
}
/**
* Set the geometry of the symbol, which represents the location of the symbol on the map
*
* @param geometry the location of the symbol
* @return this
*/
public SymbolOptions withGeometry(Point geometry) {
this.geometry = geometry;
return this;
}
/**
* Get the geometry of the symbol, which represents the location of the symbol on the map
*
* @return the location of the symbol
*/
public Point getGeometry() {
return geometry;
}
/**
* Returns whether this symbol is draggable, meaning it can be dragged across the screen when touched and moved.
*
* @return draggable when touched
*/
public boolean getDraggable() {
return isDraggable;
}
/**
* Set whether this symbol should be draggable,
* meaning it can be dragged across the screen when touched and moved.
*
* @param draggable should be draggable
*/
public SymbolOptions withDraggable(boolean draggable) {
isDraggable = draggable;
return this;
}
/**
* Set the arbitrary json data of the annotation.
*
* @param jsonElement the arbitrary json element data
*/
public SymbolOptions withData(@Nullable JsonElement jsonElement) {
this.data = jsonElement;
return this;
}
/**
* Get the arbitrary json data of the annotation.
*
* @return the arbitrary json object data if set, else null
*/
@Nullable
public JsonElement getData() {
return data;
}
@Override
Symbol build(long id, AnnotationManager<?, Symbol, ?, ?, ?, ?> annotationManager) {
if (geometry == null) {
throw new RuntimeException("geometry field is required");
}
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty(PROPERTY_SYMBOL_SORT_KEY, symbolSortKey);
jsonObject.addProperty(PROPERTY_ICON_SIZE, iconSize);
jsonObject.addProperty(PROPERTY_ICON_IMAGE, iconImage);
jsonObject.addProperty(PROPERTY_ICON_ROTATE, iconRotate);
jsonObject.add(PROPERTY_ICON_OFFSET, convertArray(iconOffset));
jsonObject.addProperty(PROPERTY_ICON_ANCHOR, iconAnchor);
jsonObject.addProperty(PROPERTY_TEXT_FIELD, textField);
jsonObject.add(PROPERTY_TEXT_FONT, convertArray(textFont));
jsonObject.addProperty(PROPERTY_TEXT_SIZE, textSize);
jsonObject.addProperty(PROPERTY_TEXT_MAX_WIDTH, textMaxWidth);
jsonObject.addProperty(PROPERTY_TEXT_LETTER_SPACING, textLetterSpacing);
jsonObject.addProperty(PROPERTY_TEXT_JUSTIFY, textJustify);
jsonObject.addProperty(PROPERTY_TEXT_RADIAL_OFFSET, textRadialOffset);
jsonObject.addProperty(PROPERTY_TEXT_ANCHOR, textAnchor);
jsonObject.addProperty(PROPERTY_TEXT_ROTATE, textRotate);
jsonObject.addProperty(PROPERTY_TEXT_TRANSFORM, textTransform);
jsonObject.add(PROPERTY_TEXT_OFFSET, convertArray(textOffset));
jsonObject.addProperty(PROPERTY_ICON_OPACITY, iconOpacity);
jsonObject.addProperty(PROPERTY_ICON_COLOR, iconColor);
jsonObject.addProperty(PROPERTY_ICON_HALO_COLOR, iconHaloColor);
jsonObject.addProperty(PROPERTY_ICON_HALO_WIDTH, iconHaloWidth);
jsonObject.addProperty(PROPERTY_ICON_HALO_BLUR, iconHaloBlur);
jsonObject.addProperty(PROPERTY_TEXT_OPACITY, textOpacity);
jsonObject.addProperty(PROPERTY_TEXT_COLOR, textColor);
jsonObject.addProperty(PROPERTY_TEXT_HALO_COLOR, textHaloColor);
jsonObject.addProperty(PROPERTY_TEXT_HALO_WIDTH, textHaloWidth);
jsonObject.addProperty(PROPERTY_TEXT_HALO_BLUR, textHaloBlur);
Symbol symbol = new Symbol(id, annotationManager, jsonObject, geometry);
symbol.setDraggable(isDraggable);
symbol.setData(data);
return symbol;
}
/**
* Creates SymbolOptions out of a Feature.
*
* @param feature feature to be converted
*/
@Nullable
static SymbolOptions fromFeature(@NonNull Feature feature) {
if (feature.geometry() == null) {
throw new RuntimeException("geometry field is required");
}
if (!(feature.geometry() instanceof Point)) {
return null;
}
SymbolOptions options = new SymbolOptions();
options.geometry = (Point) feature.geometry();
if (feature.hasProperty(PROPERTY_SYMBOL_SORT_KEY)) {
options.symbolSortKey = feature.getProperty(PROPERTY_SYMBOL_SORT_KEY).getAsFloat();
}
if (feature.hasProperty(PROPERTY_ICON_SIZE)) {
options.iconSize = feature.getProperty(PROPERTY_ICON_SIZE).getAsFloat();
}
if (feature.hasProperty(PROPERTY_ICON_IMAGE)) {
options.iconImage = feature.getProperty(PROPERTY_ICON_IMAGE).getAsString();
}
if (feature.hasProperty(PROPERTY_ICON_ROTATE)) {
options.iconRotate = feature.getProperty(PROPERTY_ICON_ROTATE).getAsFloat();
}
if (feature.hasProperty(PROPERTY_ICON_OFFSET)) {
options.iconOffset = toFloatArray(feature.getProperty(PROPERTY_ICON_OFFSET).getAsJsonArray());
}
if (feature.hasProperty(PROPERTY_ICON_ANCHOR)) {
options.iconAnchor = feature.getProperty(PROPERTY_ICON_ANCHOR).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_FIELD)) {
options.textField = feature.getProperty(PROPERTY_TEXT_FIELD).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_FONT)) {
options.textFont = toStringArray(feature.getProperty(PROPERTY_TEXT_FONT).getAsJsonArray());
}
if (feature.hasProperty(PROPERTY_TEXT_SIZE)) {
options.textSize = feature.getProperty(PROPERTY_TEXT_SIZE).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_MAX_WIDTH)) {
options.textMaxWidth = feature.getProperty(PROPERTY_TEXT_MAX_WIDTH).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_LETTER_SPACING)) {
options.textLetterSpacing = feature.getProperty(PROPERTY_TEXT_LETTER_SPACING).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_JUSTIFY)) {
options.textJustify = feature.getProperty(PROPERTY_TEXT_JUSTIFY).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_RADIAL_OFFSET)) {
options.textRadialOffset = feature.getProperty(PROPERTY_TEXT_RADIAL_OFFSET).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_ANCHOR)) {
options.textAnchor = feature.getProperty(PROPERTY_TEXT_ANCHOR).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_ROTATE)) {
options.textRotate = feature.getProperty(PROPERTY_TEXT_ROTATE).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_TRANSFORM)) {
options.textTransform = feature.getProperty(PROPERTY_TEXT_TRANSFORM).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_OFFSET)) {
options.textOffset = toFloatArray(feature.getProperty(PROPERTY_TEXT_OFFSET).getAsJsonArray());
}
if (feature.hasProperty(PROPERTY_ICON_OPACITY)) {
options.iconOpacity = feature.getProperty(PROPERTY_ICON_OPACITY).getAsFloat();
}
if (feature.hasProperty(PROPERTY_ICON_COLOR)) {
options.iconColor = feature.getProperty(PROPERTY_ICON_COLOR).getAsString();
}
if (feature.hasProperty(PROPERTY_ICON_HALO_COLOR)) {
options.iconHaloColor = feature.getProperty(PROPERTY_ICON_HALO_COLOR).getAsString();
}
if (feature.hasProperty(PROPERTY_ICON_HALO_WIDTH)) {
options.iconHaloWidth = feature.getProperty(PROPERTY_ICON_HALO_WIDTH).getAsFloat();
}
if (feature.hasProperty(PROPERTY_ICON_HALO_BLUR)) {
options.iconHaloBlur = feature.getProperty(PROPERTY_ICON_HALO_BLUR).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_OPACITY)) {
options.textOpacity = feature.getProperty(PROPERTY_TEXT_OPACITY).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_COLOR)) {
options.textColor = feature.getProperty(PROPERTY_TEXT_COLOR).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_HALO_COLOR)) {
options.textHaloColor = feature.getProperty(PROPERTY_TEXT_HALO_COLOR).getAsString();
}
if (feature.hasProperty(PROPERTY_TEXT_HALO_WIDTH)) {
options.textHaloWidth = feature.getProperty(PROPERTY_TEXT_HALO_WIDTH).getAsFloat();
}
if (feature.hasProperty(PROPERTY_TEXT_HALO_BLUR)) {
options.textHaloBlur = feature.getProperty(PROPERTY_TEXT_HALO_BLUR).getAsFloat();
}
if (feature.hasProperty(PROPERTY_IS_DRAGGABLE)) {
options.isDraggable = feature.getProperty(PROPERTY_IS_DRAGGABLE).getAsBoolean();
}
return options;
}
}