summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/circle/Circle.java
blob: 19d97b714a65c563d6435069e578de25e05b7077 (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
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.

package com.mapbox.mapboxsdk.annotations.circle;

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 Circle {

  public static final String ID_KEY = "id-circle";
  private final CircleManager circleManager;
  private final JsonObject jsonObject = new JsonObject();
  private Geometry geometry;

  /**
   * Create a circle.
   *
   * @param manager the circle manager created and managing the circle
   * @param id            the id of the circle
   */
  Circle(CircleManager manager, long id) {
    this.circleManager = manager;
    this.jsonObject.addProperty(ID_KEY, id);
  }

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

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

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

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

  // Property accessors
  /**
   * Get the CircleRadius property
   *
   * @return property wrapper value around Float
   */
  
  public Float getCircleRadius() {
    return jsonObject.get("circle-radius").getAsFloat();
  }

  /**
   * Set the CircleRadius property
   *
   * @param value constant property value for Float
   */
  public void setCircleRadius( Float value) {
    jsonObject.addProperty("circle-radius", value);
    circleManager.updateSource();
  }

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

  /**
   * Set the CircleColor property
   *
   * @param value constant property value for String
   */
  public void setCircleColor( String value) {
    jsonObject.addProperty("circle-color", value);
    circleManager.updateSource();
  }

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

  /**
   * Set the CircleBlur property
   *
   * @param value constant property value for Float
   */
  public void setCircleBlur( Float value) {
    jsonObject.addProperty("circle-blur", value);
    circleManager.updateSource();
  }

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

  /**
   * Set the CircleOpacity property
   *
   * @param value constant property value for Float
   */
  public void setCircleOpacity( Float value) {
    jsonObject.addProperty("circle-opacity", value);
    circleManager.updateSource();
  }

  /**
   * Get the CircleStrokeWidth property
   *
   * @return property wrapper value around Float
   */
  
  public Float getCircleStrokeWidth() {
    return jsonObject.get("circle-stroke-width").getAsFloat();
  }

  /**
   * Set the CircleStrokeWidth property
   *
   * @param value constant property value for Float
   */
  public void setCircleStrokeWidth( Float value) {
    jsonObject.addProperty("circle-stroke-width", value);
    circleManager.updateSource();
  }

  /**
   * Get the CircleStrokeColor property
   *
   * @return property wrapper value around String
   */
  
  public String getCircleStrokeColor() {
    return jsonObject.get("circle-stroke-color").getAsString();
  }

  /**
   * Set the CircleStrokeColor property
   *
   * @param value constant property value for String
   */
  public void setCircleStrokeColor( String value) {
    jsonObject.addProperty("circle-stroke-color", value);
    circleManager.updateSource();
  }

  /**
   * Get the CircleStrokeOpacity property
   *
   * @return property wrapper value around Float
   */
  
  public Float getCircleStrokeOpacity() {
    return jsonObject.get("circle-stroke-opacity").getAsFloat();
  }

  /**
   * Set the CircleStrokeOpacity property
   *
   * @param value constant property value for Float
   */
  public void setCircleStrokeOpacity( Float value) {
    jsonObject.addProperty("circle-stroke-opacity", value);
    circleManager.updateSource();
  }

}