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

package com.mapbox.mapboxsdk.style.layers;

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

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.google.gson.JsonArray;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;

/**
 * The background color or pattern of the map.
 *
 * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-background">The online documentation</a>
 */
@UiThread
public class BackgroundLayer extends Layer {

  /**
   * Creates a BackgroundLayer.
   *
   * @param nativePtr pointer used by core
   */
  public BackgroundLayer(long nativePtr) {
    super(nativePtr);
  }

  /**
   * Creates a BackgroundLayer.
   *
   * @param layerId the id of the layer
   */
  public BackgroundLayer(String layerId) {
    initialize(layerId);
  }

  protected native void initialize(String layerId);

  /**
   * Set a property or properties.
   *
   * @param properties the var-args properties
   * @return This
   */
  public BackgroundLayer withProperties(@NonNull PropertyValue<?>... properties) {
    setProperties(properties);
    return this;
  }

  // Property getters

  /**
   * Get the BackgroundColor property
   *
   * @return property wrapper value around String
   */
  @SuppressWarnings("unchecked")
  public PropertyValue<String> getBackgroundColor() {
    return (PropertyValue<String>) new PropertyValue("background-color", nativeGetBackgroundColor());
  }

  /**
   * The color with which the background will be drawn.
   *
   * @return int representation of a rgba string color
   * @throws RuntimeException thrown if property isn't a value
   */
  @ColorInt
  public int getBackgroundColorAsInt() {
    PropertyValue<String> value = getBackgroundColor();
    if (value.isValue()) {
      return rgbaToColor(value.getValue());
    } else {
      throw new RuntimeException("background-color was set as a Function");
    }
  }

  /**
   * Get the BackgroundColor property transition options
   *
   * @return transition options for String
   */
  public TransitionOptions getBackgroundColorTransition() {
    return nativeGetBackgroundColorTransition();
  }

  /**
   * Set the BackgroundColor property transition options
   *
   * @param options transition options for String
   */
  public void setBackgroundColorTransition(TransitionOptions options) {
    nativeSetBackgroundColorTransition(options.getDuration(), options.getDelay());
  }

  /**
   * Get the BackgroundPattern property
   *
   * @return property wrapper value around String
   */
  @SuppressWarnings("unchecked")
  public PropertyValue<String> getBackgroundPattern() {
    return (PropertyValue<String>) new PropertyValue("background-pattern", nativeGetBackgroundPattern());
  }

  /**
   * Get the BackgroundPattern property transition options
   *
   * @return transition options for String
   */
  public TransitionOptions getBackgroundPatternTransition() {
    return nativeGetBackgroundPatternTransition();
  }

  /**
   * Set the BackgroundPattern property transition options
   *
   * @param options transition options for String
   */
  public void setBackgroundPatternTransition(TransitionOptions options) {
    nativeSetBackgroundPatternTransition(options.getDuration(), options.getDelay());
  }

  /**
   * Get the BackgroundOpacity property
   *
   * @return property wrapper value around Float
   */
  @SuppressWarnings("unchecked")
  public PropertyValue<Float> getBackgroundOpacity() {
    return (PropertyValue<Float>) new PropertyValue("background-opacity", nativeGetBackgroundOpacity());
  }

  /**
   * Get the BackgroundOpacity property transition options
   *
   * @return transition options for Float
   */
  public TransitionOptions getBackgroundOpacityTransition() {
    return nativeGetBackgroundOpacityTransition();
  }

  /**
   * Set the BackgroundOpacity property transition options
   *
   * @param options transition options for Float
   */
  public void setBackgroundOpacityTransition(TransitionOptions options) {
    nativeSetBackgroundOpacityTransition(options.getDuration(), options.getDelay());
  }

  private native Object nativeGetBackgroundColor();

  private native TransitionOptions nativeGetBackgroundColorTransition();

  private native void nativeSetBackgroundColorTransition(long duration, long delay);

  private native Object nativeGetBackgroundPattern();

  private native TransitionOptions nativeGetBackgroundPatternTransition();

  private native void nativeSetBackgroundPatternTransition(long duration, long delay);

  private native Object nativeGetBackgroundOpacity();

  private native TransitionOptions nativeGetBackgroundOpacityTransition();

  private native void nativeSetBackgroundOpacityTransition(long duration, long delay);

  @Override
  protected native void finalize() throws Throwable;

}