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

import android.graphics.Point;
import android.graphics.PointF;
import android.os.Parcelable;
import android.support.annotation.AnimatorRes;
import android.support.annotation.NonNull;

import com.mapbox.mapboxsdk.geometry.LatLng;

/**
 * Abstract builder class for composing custom MarkerView objects.
 * <p>
 * Extending this class requires implementing Parceable interface.
 *
 * @param <U> Type of the marker view to be composed
 * @param <T> Type of the builder to be used for composing a custom Marker
 */
public abstract class BaseMarkerViewOptions<U extends MarkerView, T extends BaseMarkerViewOptions<U, T>> implements Parcelable {

    protected LatLng position;
    protected String snippet;
    protected String title;
    protected Icon icon;
    protected boolean flat;
    protected PointF centerOffset;
    protected Point infoWindowOffset;
    protected int selectAnimRes;
    protected int deselectAnimRes;
    protected int rotation;

    public BaseMarkerViewOptions() {
        centerOffset = new PointF();
        infoWindowOffset = new Point();
    }

    public T position(@NonNull LatLng position) {
        this.position = position;
        return getThis();
    }

    public T snippet(String snippet) {
        this.snippet = snippet;
        return getThis();
    }

    public T title(String title) {
        this.title = title;
        return getThis();
    }

    public T icon(Icon icon) {
        this.icon = icon;
        return getThis();
    }

    public T flat(boolean flat) {
        this.flat = flat;
        return getThis();
    }

    public T centerOffset(PointF centerOffset) {
        this.centerOffset = centerOffset;
        return getThis();
    }

    public T infoWindowOffset(Point infoWindowOffset) {
        this.infoWindowOffset = infoWindowOffset;
        return getThis();
    }

    public T selectAnimatorResource(@AnimatorRes int selectAnimRes) {
        this.selectAnimRes = selectAnimRes;
        return getThis();
    }

    public T deselectAnimatorResource(@AnimatorRes int deselectAnimRes) {
        this.deselectAnimRes = deselectAnimRes;
        return getThis();
    }

    public T rotation(int rotation){
        this.rotation = rotation;
        return getThis();
    }

    public LatLng getPosition() {
        return position;
    }

    public String getSnippet() {
        return snippet;
    }

    public String getTitle() {
        return title;
    }

    public Icon getIcon() {
        return icon;
    }

    public boolean isFlat() {
        return flat;
    }

    public PointF getCenterOffset() {
        return centerOffset;
    }

    public Point getInfoWindowOffset() {
        return infoWindowOffset;
    }

    public int getSelectAnimRes() {
        return selectAnimRes;
    }

    public int getDeselectAnimRes() {
        return deselectAnimRes;
    }

    public int getRotation() {
        return rotation;
    }

    public abstract T getThis();

    public abstract U getMarker();

}