summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/light/light.java.ejs
blob: f3e7c31a4f0e4fd33b162465452b02b05448a4ec (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
<%
  const properties = locals.properties;
  const doc = locals.doc;
-%>
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.

package com.mapbox.mapboxsdk.style.light;

import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.annotation.UiThread;

import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

/**
 * The global light source.
 *
 * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#light">The online documentation</a>
 */
@UiThread
public class Light {

  private long nativePtr;

  /**
   * Creates a Light.
   *
   * @param nativePtr pointer used by core
   */
  public Light(long nativePtr) {
    checkThread();
    this.nativePtr = nativePtr;
  }
<% for (const property of properties) { -%>
<% if (property.name == "position") {-%>

  /**
   * Set the <%- camelize(property.name) %> property. <%- property.doc %>
   *
   * @param position of the light
   */
  public void set<%- camelize(property.name) %>(@NonNull Position position) {
    checkThread();
    nativeSet<%- camelize(property.name) %>(position);
  }

  /**
   * Get the <%- camelize(property.name) %> property. <%- property.doc %>
   *
   * @return <%- property.name %> as Position
   */
  public Position get<%- camelize(property.name) %>() {
    checkThread();
    return nativeGet<%- camelize(property.name) %>();
  }
<% } else { -%>
<% if (property.name == "color") {-%>

  /**
   * Set the <%- camelize(property.name) %> property. <%- property.doc %>
   *
   * @param <%- property.name %> as int
   */
  public void set<%- camelize(property.name) %>(@ColorInt int <%- property.name %>) {
    checkThread();
    nativeSet<%- camelize(property.name) %>(PropertyFactory.colorToRgbaString(<%- property.name %>));
  }
<% } -%>

  /**
   * Set the <%- camelize(property.name) %> property. <%- property.doc %>
   *
   * @param <%- property.name %> as <%- propertyType(property) %>
   */
  public void set<%- camelize(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyJavaType(property) %> <%- property.name %>) {
    checkThread();
    nativeSet<%- camelize(property.name) %>(<%- property.name %>);
  }

  /**
   * Get the <%- camelize(property.name) %> property. <%- property.doc %>
   *
   * @return <%- property.name %> as <%- propertyType(property) %>
   */
  <%- propertyTypeAnnotation(property) %> public <%- propertyJavaType(property) %> get<%- camelize(property.name) %>() {
    checkThread();
    return nativeGet<%- camelize(property.name) %>();
  }
<% } -%>
<% if (property.transition) { -%>

  /**
   * Get the <%- camelize(property.name) %> property transition options.
   *
   * @return transition options for <%- property.name %>
   */
  public TransitionOptions get<%- camelize(property.name) %>Transition() {
    checkThread();
    return nativeGet<%- camelize(property.name) %>Transition();
  }

  /**
   * Set the <%- camelize(property.name) %> property transition options.
   *
   * @param options transition options for <%- property.name %>
   */
  public void set<%- camelize(property.name) %>Transition(TransitionOptions options) {
    checkThread();
    nativeSet<%- camelize(property.name) %>Transition(options.getDuration(), options.getDelay());
  }
<% } -%>
<% } -%>

  private void checkThread(){
    ThreadUtils.checkThread("Light");
  }

<% for (const property of properties) { -%>
<% if (property.name == "position") {-%>
  private native void nativeSet<%- camelize(property.name) %>(Position position);
  private native Position nativeGet<%- camelize(property.name) %>();
<% } else { -%>
  private native void nativeSet<%- camelize(property.name) %>(<%- propertyJavaType(property) -%> <%- property.name %>);
  private native <%- propertyJavaType(property) -%> nativeGet<%- camelize(property.name) %>();
<% } -%>
<% if (property.transition) { -%>
  private native TransitionOptions nativeGet<%- camelize(property.name) %>Transition();
  private native void nativeSet<%- camelize(property.name) %>Transition(long duration, long delay);
<% } -%>
<% } -%>
}