diff options
author | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
---|---|---|
committer | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
commit | 9e8dc9a9e3e86adb9987ae69766cc42c7d9efece (patch) | |
tree | f5f0abd4d342c89ad0405d01969f9d6caecc1c90 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java | |
parent | 16fb0672e64a72b7400c321d55858b73cd5d8c3f (diff) | |
parent | f28d75dccd9bf4a7615df87faccc5cf5eff8df89 (diff) | |
download | qtlocation-mapboxgl-9e8dc9a9e3e86adb9987ae69766cc42c7d9efece.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/custom-vector-source
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java new file mode 100644 index 0000000000..d47aa1fc91 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops.java @@ -0,0 +1,97 @@ +package com.mapbox.mapboxsdk.style.functions.stops; + +import android.support.annotation.NonNull; +import android.support.annotation.Size; + +import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; + +/** + * The {@link Stops} implementation for exponential functions + * + * @param <I> the input type + * @param <O> the output type + */ +public class ExponentialStops<I, O> extends IterableStops<I, O, Stop<I, O>> { + + private float base; + private final Stop<I, O>[] stops; + + /** + * Create exponential stops with an explicit base. Use through {@link Stops#exponential(Stop[])} + * + * @param base The exponential base of the interpolation curve. It controls the rate at which the function output + * increases. Higher values make the output increase more towards the high end of the range. + * With values close to 1 the output increases linearly. + * @param stops the stops + */ + @SafeVarargs + public ExponentialStops(Float base, @NonNull @Size(min = 1) Stop<I, O>... stops) { + this.base = base != null ? base : 1.0f; + this.stops = stops; + } + + /** + * Create exponential stops without an explicit base. Use through {@link Stops#exponential(Stop[])} + * + * @param stops the stops + */ + @SafeVarargs + public ExponentialStops(@NonNull @Size(min = 1) Stop<I, O>... stops) { + this(null, stops); + } + + /** + * Set the exponential base + * + * @param base the base to use in the exponential function + * @return this (for chaining) + */ + public ExponentialStops<I, O> withBase(float base) { + this.base = base; + return this; + } + + /** + * @return The exponential base + */ + public float getBase() { + return base; + } + + /** + * {@inheritDoc} + */ + @Override + public Map<String, Object> toValueObject() { + Map<String, Object> map = super.toValueObject(); + map.put("base", base); + map.put("stops", toValueObjects(stops)); + return map; + } + + /** + * {@inheritDoc} + */ + @Override + public String getTypeName() { + return "exponential"; + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator<Stop<I, O>> iterator() { + return Arrays.asList(stops).iterator(); + } + + /** + * {@inheritDoc} + */ + @Override + public int size() { + return stops.length; + } +} |