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

import com.mapbox.mapboxsdk.geometry.LatLng;

import java.util.ArrayList;
import java.util.List;

/**
 * Multipoint is an abstract annotation for combining geographical locations.
 */
public abstract class MultiPoint extends Annotation {

    private List<LatLng> points;
    private float alpha = 1.0f;

    protected MultiPoint() {
        super();
        points = new ArrayList<>();
    }

    /**
     * Returns a copy of the points.
     *
     * @return A {@link List} of points.
     */
    public List<LatLng> getPoints() {
        return new ArrayList<>(points);
    }

    /**
     * Sets the points of this polyline. This method will take a copy of the points, so further
     * mutations to points will have no effect on this polyline.
     *
     * @param points A {@link List} of {@link LatLng} points making up the polyline.
     */
    public void setPoints(List<LatLng> points) {
        this.points = new ArrayList<>(points);
        update();
    }

    /**
     * Add a point to the polyline.
     *
     * @param point A {@link LatLng} point to be added.
     */
    public void addPoint(LatLng point) {
        points.add(point);
        update();
    }

    /**
     * Value between 0 and 1 defining the polyline alpha.
     *
     * @return float value between 0 and 1.
     */
    public float getAlpha() {
        return alpha;
    }

    /**
     * Set this {@link MultiPoint}s alpha.
     *
     * @param alpha float value between 0 and 1.
     */
    public void setAlpha(float alpha) {
        this.alpha = alpha;
        update();
    }

    abstract void update();
}