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

import com.mapbox.mapboxsdk.exceptions.ConversionException;

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

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

/**
 * Background Layer
 */
public class BackgroundLayer extends Layer {

    public BackgroundLayer(long nativePtr) {
        super(nativePtr);
    }

    public BackgroundLayer(String layerId) {
        initialize(layerId);
    }

    protected native void initialize(String layerId);


    public BackgroundLayer withProperties(@NonNull Property<?>... properties) {
        setProperties(properties);
        return this;
    }

    // Property getters

    @SuppressWarnings("unchecked")
    public PropertyValue<String> getBackgroundColor() {
        checkValidity();
        return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundColor());
    }
      /**
      * The color with which the background will be drawn.
      * @throws RuntimeException
      */
    @ColorInt
    public int getBackgroundColorAsInt() {
        checkValidity();
        PropertyValue<String> value = getBackgroundColor();
        if (value.isValue()) {
            return rgbaToColor(value.getValue());
        } else {
            throw new RuntimeException("background-color was set as a Function");
        }
    }

 
    @SuppressWarnings("unchecked")
    public PropertyValue<String> getBackgroundPattern() {
        checkValidity();
        return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundPattern());
    }
 
    @SuppressWarnings("unchecked")
    public PropertyValue<Float> getBackgroundOpacity() {
        checkValidity();
        return (PropertyValue<Float>) new PropertyValue(nativeGetBackgroundOpacity());
    }
 
    private native Object nativeGetBackgroundColor();

    private native Object nativeGetBackgroundPattern();

    private native Object nativeGetBackgroundOpacity();


    @Override
    protected native void finalize() throws Throwable;

}