summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Polygon.java
blob: a06938e3cb078bcb09e27fc8c5fddd86297a5882 (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
package com.mapbox.mapboxsdk.annotations;

import android.graphics.Color;

import com.mapbox.mapboxsdk.maps.MapboxMap;

/**
 * Polygon is a geometry annotation that's a closed loop of coordinates.
 */
public final class Polygon extends MultiPoint {

    private int fillColor = Color.BLACK; // default fillColor is black
    private int strokeColor = Color.BLACK; // default strokeColor is black

    Polygon() {
        super();
    }

    /**
     * Get the color of the fill region of the polygon.
     *
     * @return The color of the fill.
     */
    public int getFillColor() {
        return fillColor;
    }

    /**
     * Get the color fo the stroke of the polygon.
     *
     * @return The color of the stroke.
     */
    public int getStrokeColor() {
        return strokeColor;
    }

    /**
     * Sets the color of the fill region of the polygon.
     *
     * @param color The color in ARGB format.
     */
    public void setFillColor(int color) {
        fillColor = color;
        update();
    }

    /**
     * Sets the color of the stroke of the polygon.
     *
     * @param color The color in ARGB format.
     */
    public void setStrokeColor(int color) {
        strokeColor = color;
        update();
    }

    @Override
    void update() {
        MapboxMap mapboxMap = getMapboxMap();
        if (mapboxMap != null) {
            mapboxMap.updatePolygon(this);
        }
    }
}