[android] data driven style implementation
This commit is contained in:
committed by
John Firebaugh
parent
8a5bff8ee6
commit
f562ecdfc3
@@ -12,6 +12,9 @@ task checkstyle(type: Checkstyle) {
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
exclude '**/style/layers/Property.java'
|
||||
exclude '**/style/layers/PropertyFactory.java'
|
||||
exclude '**/style/layers/*Layer.java'
|
||||
classpath = files()
|
||||
ignoreFailures = false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mapbox.mapboxsdk.style.functions;
|
||||
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
|
||||
/**
|
||||
* Camera function. Functions that take camera properties as input (zoom for now)
|
||||
* <p>
|
||||
* Zoom functions allow the appearance of a map feature to change with map’s zoom level.
|
||||
* Zoom functions can be used to create the illusion of depth and control data density.
|
||||
* Each stop is an array with two elements: the first is a zoom level and the second is
|
||||
* a function output value.
|
||||
*
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
* @see Function#zoom
|
||||
*/
|
||||
public class CameraFunction<I extends Number, O> extends Function<I, O> {
|
||||
|
||||
/**
|
||||
* Create an exponential camera function
|
||||
*
|
||||
* @param stops @see {@link com.mapbox.mapboxsdk.style.functions.stops.Stops#exponential(float, Stop[])}
|
||||
*/
|
||||
CameraFunction(@NonNull ExponentialStops<I, O> stops) {
|
||||
super(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interval camera function
|
||||
*
|
||||
* @param stops @see {@link com.mapbox.mapboxsdk.style.functions.stops.Stops#interval(Stop[])}
|
||||
*/
|
||||
CameraFunction(@NonNull IntervalStops<I, O> stops) {
|
||||
super(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* JNI constructor
|
||||
*/
|
||||
@Keep
|
||||
private CameraFunction(Stops<I, O> stops) {
|
||||
super(stops);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mapbox.mapboxsdk.style.functions;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Composite functions combine {@link android.graphics.Camera} and {@link SourceFunction}s.
|
||||
* <p>
|
||||
* Composite functions allow the appearance of a map feature to change with both its
|
||||
* properties and zoom. Each stop is an array with two elements, the first is an object
|
||||
* with a property input value and a zoom, and the second is a function output value. Note
|
||||
* that support for property functions is not yet complete.
|
||||
*
|
||||
* @param <Z> the zoom type (usually Float)
|
||||
* @param <I> the input type (the feature property type)
|
||||
* @param <O> the output type (the property type)
|
||||
* @see Function#composite
|
||||
*/
|
||||
public class CompositeFunction<Z extends Number, I, O> extends Function<I, O> {
|
||||
|
||||
private final String property;
|
||||
private O defaultValue;
|
||||
|
||||
CompositeFunction(@NonNull String property,
|
||||
@NonNull CompositeStops<Z, I, O, ? extends Stops<I, O>> stops) {
|
||||
this(null, property, stops);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* JNI Constructor
|
||||
*/
|
||||
private CompositeFunction(@Nullable O defaultValue, @NonNull String property,
|
||||
@NonNull CompositeStops<Z, I, O, ? extends Stops<I, O>> stops) {
|
||||
super(stops);
|
||||
this.defaultValue = defaultValue;
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @param defaultValue the default value to use when no other applies
|
||||
* @return this (for chaining)
|
||||
*/
|
||||
public CompositeFunction<Z, I, O> withDefaultValue(O defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
@Nullable
|
||||
public O getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return the feature property name
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> valueObject = super.toValueObject();
|
||||
valueObject.put(PROPERTY_KEY, property);
|
||||
if (defaultValue != null) {
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue);
|
||||
}
|
||||
return valueObject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
package com.mapbox.mapboxsdk.style.functions;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
* Functions are used to change properties in relation to the state of the map.
|
||||
* <p>
|
||||
* The value for any layout or paint property may be specified as a function. Functions allow you to
|
||||
* make the appearance of a map feature change with the current zoom level and/or the feature's properties.
|
||||
*
|
||||
* @param <I> the function's input type
|
||||
* @param <O> the target property's value type. Make sure it matches.
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a>
|
||||
*/
|
||||
public class Function<I, O> {
|
||||
|
||||
static final String PROPERTY_KEY = "property";
|
||||
static final String DEFAULT_VALUE_KEY = "defaultValue";
|
||||
|
||||
/**
|
||||
* Create an exponential {@link CameraFunction}
|
||||
* <p>
|
||||
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
|
||||
* Zoom functions can be used to create the illusion of depth and control data density.
|
||||
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
|
||||
*
|
||||
* @param <Z> the zoom level type (Float, Integer)
|
||||
* @param <O> the property type
|
||||
* @param stops the stops implementation that define the function. @see {@link Stops#exponential(Stop[])}
|
||||
* @return the {@link CameraFunction}
|
||||
* @see CameraFunction
|
||||
* @see ExponentialStops
|
||||
* @see Stops#exponential(Stop[])
|
||||
* @see Stops#exponential(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <Z extends Number, O> CameraFunction<Z, O> zoom(@NonNull ExponentialStops<Z, O> stops) {
|
||||
return new CameraFunction<>(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interval {@link CameraFunction}
|
||||
* <p>
|
||||
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
|
||||
* Zoom functions can be used to create the illusion of depth and control data density.
|
||||
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
|
||||
*
|
||||
* @param <Z> the zoom level type (Float, Integer)
|
||||
* @param <O> the property type
|
||||
* @param stops the stops implementation that define the function. @see {@link Stops#interval(Stop[])}
|
||||
* @return the {@link CameraFunction}
|
||||
* @see CameraFunction
|
||||
* @see IntervalStops
|
||||
* @see Stops#interval(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <Z extends Number, O> CameraFunction<Z, O> zoom(@NonNull IntervalStops<Z, O> stops) {
|
||||
return new CameraFunction<>(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an exponential {@link SourceFunction}
|
||||
* <p>
|
||||
* Source functions allow the appearance of a map feature to change with
|
||||
* its properties. Source functions can be used to visually differentiate
|
||||
* types of features within the same layer or create data visualizations.
|
||||
* Each stop is an array with two elements, the first is a property input
|
||||
* value and the second is a function output value. Note that support for
|
||||
* property functions is not available across all properties and platforms
|
||||
* at this time.
|
||||
*
|
||||
* @param property the feature property name
|
||||
* @param stops the stops
|
||||
* @param <I> the function input type
|
||||
* @param <O> the function output type
|
||||
* @return the {@link SourceFunction}
|
||||
* @see SourceFunction
|
||||
* @see ExponentialStops
|
||||
* @see Stops#exponential(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <I, O> SourceFunction<I, O> property(@NonNull String property, @NonNull ExponentialStops<I, O> stops) {
|
||||
return new SourceFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an identity {@link SourceFunction}
|
||||
* <p>
|
||||
* Source functions allow the appearance of a map feature to change with
|
||||
* its properties. Source functions can be used to visually differentiate
|
||||
* types of features within the same layer or create data visualizations.
|
||||
* Each stop is an array with two elements, the first is a property input
|
||||
* value and the second is a function output value. Note that support for
|
||||
* property functions is not available across all properties and platforms
|
||||
* at this time.
|
||||
*
|
||||
* @param property the feature property name
|
||||
* @param stops the stops
|
||||
* @param <T> the function input/output type
|
||||
* @return the {@link SourceFunction}
|
||||
* @see SourceFunction
|
||||
* @see IdentityStops
|
||||
* @see Stops#identity()
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <T> SourceFunction<T, T> property(@NonNull String property, @NonNull IdentityStops<T> stops) {
|
||||
return new SourceFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interval {@link SourceFunction}
|
||||
* <p>
|
||||
* Source functions allow the appearance of a map feature to change with
|
||||
* its properties. Source functions can be used to visually differentiate
|
||||
* types of features within the same layer or create data visualizations.
|
||||
* Each stop is an array with two elements, the first is a property input
|
||||
* value and the second is a function output value. Note that support for
|
||||
* property functions is not available across all properties and platforms
|
||||
* at this time.
|
||||
*
|
||||
* @param property the feature property name
|
||||
* @param stops the stops
|
||||
* @param <I> the function input type
|
||||
* @param <O> the function output type
|
||||
* @return the {@link SourceFunction}
|
||||
* @see SourceFunction
|
||||
* @see IntervalStops
|
||||
* @see Stops#interval(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <I, O> SourceFunction<I, O> property(@NonNull String property, @NonNull IntervalStops<I, O> stops) {
|
||||
return new SourceFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an categorical {@link SourceFunction}
|
||||
* <p>
|
||||
* Source functions allow the appearance of a map feature to change with
|
||||
* its properties. Source functions can be used to visually differentiate
|
||||
* types of features within the same layer or create data visualizations.
|
||||
* Each stop is an array with two elements, the first is a property input
|
||||
* value and the second is a function output value. Note that support for
|
||||
* property functions is not available across all properties and platforms
|
||||
* at this time.
|
||||
*
|
||||
* @param property the feature property name
|
||||
* @param stops the stops
|
||||
* @param <I> the function input type
|
||||
* @param <O> the function output type
|
||||
* @return the {@link SourceFunction}
|
||||
* @see SourceFunction
|
||||
* @see CategoricalStops
|
||||
* @see Stops#categorical(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <I, O> SourceFunction<I, O> property(@NonNull String property, @NonNull CategoricalStops<I, O> stops) {
|
||||
return new SourceFunction<>(property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a composite, categorical function.
|
||||
* <p>
|
||||
* Composite functions allow the appearance of a map feature to change with both its
|
||||
* properties and zoom. Each stop is an array with two elements, the first is an object
|
||||
* with a property input value and a zoom, and the second is a function output value. Note
|
||||
* that support for property functions is not yet complete.
|
||||
*
|
||||
* @param property the feature property name for the source part of the function
|
||||
* @param stops the stops
|
||||
* @param <Z> the zoom function input type (Float usually)
|
||||
* @param <I> the function input type for the source part of the function
|
||||
* @param <O> the function output type
|
||||
* @return the {@link CompositeFunction}
|
||||
* @see CompositeFunction
|
||||
* @see CategoricalStops
|
||||
* @see Stops#categorical(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <Z extends Number, I, O> CompositeFunction<Z, I, O> composite(
|
||||
@NonNull String property,
|
||||
@NonNull CategoricalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a composite, exponential function.
|
||||
* <p>
|
||||
* Composite functions allow the appearance of a map feature to change with both its
|
||||
* properties and zoom. Each stop is an array with two elements, the first is an object
|
||||
* with a property input value and a zoom, and the second is a function output value. Note
|
||||
* that support for property functions is not yet complete.
|
||||
*
|
||||
* @param property the feature property name for the source part of the function
|
||||
* @param stops the stops
|
||||
* @param <Z> the zoom function input type (Float usually)
|
||||
* @param <I> the function input type for the source part of the function
|
||||
* @param <O> the function output type
|
||||
* @return the {@link CompositeFunction}
|
||||
* @see CompositeFunction
|
||||
* @see ExponentialStops
|
||||
* @see Stops#exponential(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <Z extends Number, I, O> CompositeFunction<Z, I, O> composite(
|
||||
@NonNull String property,
|
||||
@NonNull ExponentialStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a composite, interval function.
|
||||
* <p>
|
||||
* Composite functions allow the appearance of a map feature to change with both its
|
||||
* properties and zoom. Each stop is an array with two elements, the first is an object
|
||||
* with a property input value and a zoom, and the second is a function output value. Note
|
||||
* that support for property functions is not yet complete.
|
||||
*
|
||||
* @param property the feature property name for the source part of the function
|
||||
* @param stops the stops
|
||||
* @param <Z> the zoom function input type (Float usually)
|
||||
* @param <I> the function input type for the source part of the function
|
||||
* @param <O> the function output type
|
||||
* @return the {@link CompositeFunction}
|
||||
* @see CompositeFunction
|
||||
* @see IntervalStops
|
||||
* @see Stops#interval(Stop[])
|
||||
* @see Stop#stop
|
||||
*/
|
||||
public static <Z extends Number, I, O> CompositeFunction<Z, I, O> composite(
|
||||
@NonNull String property,
|
||||
@NonNull IntervalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
|
||||
return new CompositeFunction<>(property, new CompositeStops<>(stops));
|
||||
}
|
||||
|
||||
// Class definition //
|
||||
|
||||
private final Stops<I, O> stops;
|
||||
|
||||
/**
|
||||
* JNI Cosntructor for implementation classes
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
Function(@NonNull Stops stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stops in this function
|
||||
*/
|
||||
public Stops getStops() {
|
||||
return stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method
|
||||
*
|
||||
* @param <S> the Stops implementation type
|
||||
* @return the Stops implementation or null when the wrong type is specified
|
||||
*/
|
||||
@Nullable
|
||||
public <S extends Stops> S getStopsAs() {
|
||||
try {
|
||||
// noinspection unchecked
|
||||
return (S) stops;
|
||||
} catch (ClassCastException exception) {
|
||||
Timber.e(String.format("Stops: %s is a different type: %s", stops.getClass(), exception));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return a value object representation for core conversion
|
||||
*/
|
||||
public Map<String, Object> toValueObject() {
|
||||
return stops.toValueObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s: %s", getClass().getSimpleName(), stops);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.mapbox.mapboxsdk.style.functions;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Source functions take Feature property names as input.
|
||||
* <p>
|
||||
* Source functions allow the appearance of a map feature to change with
|
||||
* its properties. Source functions can be used to visually differentiate
|
||||
* types of features within the same layer or create data visualizations.
|
||||
* Each stop is an array with two elements, the first is a property input
|
||||
* value and the second is a function output value. Note that support for
|
||||
* property functions is not available across all properties and platforms
|
||||
* at this time.
|
||||
*
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
* @see Function#property
|
||||
*/
|
||||
public class SourceFunction<I, O> extends Function<I, O> {
|
||||
|
||||
private final String property;
|
||||
private O defaultValue;
|
||||
|
||||
SourceFunction(@NonNull String property, @NonNull Stops<I, O> stops) {
|
||||
this(null, property, stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* JNI Constructor
|
||||
*/
|
||||
private SourceFunction(@Nullable O defaultValue, @NonNull String property, @NonNull Stops<I, O> stops) {
|
||||
super(stops);
|
||||
this.property = property;
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return The feature property name
|
||||
*/
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default value
|
||||
*
|
||||
* @param defaultValue the default value to use when no other applies
|
||||
* @return this (for chaining)
|
||||
*/
|
||||
public SourceFunction<I, O> withDefaultValue(O defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the defaultValue
|
||||
*/
|
||||
@Nullable
|
||||
public O getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> valueObject = super.toValueObject();
|
||||
valueObject.put(PROPERTY_KEY, property);
|
||||
if (defaultValue != null) {
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue);
|
||||
}
|
||||
return valueObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Contains the Mapbox Maps Android Style Function API classes.
|
||||
*
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a>
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.style.functions;
|
||||
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* {@link Stops} implementation for categorical functions
|
||||
*
|
||||
* @param <I> the {@link Stop} input type
|
||||
* @param <O> the {@link Stop} output type
|
||||
*/
|
||||
public class CategoricalStops<I, O> extends IterableStops<I, O, Stop<I, O>> {
|
||||
|
||||
private final Stop<I, O>[] stops;
|
||||
|
||||
/**
|
||||
* Create a categorical {@link Stops} implementation. Use through {@link Stops#categorical(Stop[])}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
@SafeVarargs
|
||||
public CategoricalStops(@NonNull @Size(min = 1) Stop<I, O>... stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> map = super.toValueObject();
|
||||
map.put("stops", toValueObjects(stops));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "categorical";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Stop<I, O>> iterator() {
|
||||
return Arrays.asList(stops).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return stops.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import android.support.annotation.Keep;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop.CompositeValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The {@link Stops} implementation for composite functions
|
||||
*
|
||||
* @param <Z> the zoom type (usually Float)
|
||||
* @param <I> the input type (the feature property type)
|
||||
* @param <O> the output type (the property type)
|
||||
* @param <S> the {@link Stops} implementation (eg CategoricalStops, {@link ExponentialStops} or {@link IntervalStops})
|
||||
*/
|
||||
public class CompositeStops<Z extends Number, I, O, S extends IterableStops<I, O, Stop<I, O>>>
|
||||
extends IterableStops<CompositeValue<Z, I>, O, Map.Entry<Z, S>> {
|
||||
|
||||
private final Map<Z, S> stops;
|
||||
|
||||
/**
|
||||
* JNI Constructor
|
||||
*
|
||||
* @param stops the stops {@link Map}
|
||||
*/
|
||||
@Keep
|
||||
private CompositeStops(@NonNull @Size(min = 1) Map<Z, S> stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link ExponentialStops}. Use
|
||||
* {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, ExponentialStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull ExponentialStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(),
|
||||
(S) new ExponentialStops<>(stops.getBase(), entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link IntervalStops}.
|
||||
* Use {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, IntervalStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull IntervalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(), (S) new IntervalStops<>(entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create composite stops for {@link CategoricalStops}.
|
||||
* Use {@link com.mapbox.mapboxsdk.style.functions.Function#composite(String, CategoricalStops)}
|
||||
*
|
||||
* @param stops the stops
|
||||
*/
|
||||
public CompositeStops(@NonNull CategoricalStops<CompositeValue<Z, I>, O> stops) {
|
||||
this.stops = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Z, List<Stop<I, O>>> entry : collect(stops).entrySet()) {
|
||||
// noinspection unchecked
|
||||
this.stops.put(entry.getKey(), (S) new CategoricalStops<>(entry.getValue().toArray(new Stop[0])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return stops.values().iterator().next().getTypeName();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> map = super.toValueObject();
|
||||
|
||||
// Flatten and toValueObjects stops
|
||||
// noinspection unchecked
|
||||
map.put("stops", toValueObjects(flatten(this.stops).toArray(new Stop[0])));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private List<Stop<CompositeValue<Z, I>, O>> flatten(Map<Z, S> stops) {
|
||||
List<Stop<CompositeValue<Z, I>, O>> flattenedStops = new ArrayList<>();
|
||||
for (Map.Entry<Z, S> entry : stops.entrySet()) {
|
||||
for (Stop<I, O> stop : entry.getValue()) {
|
||||
flattenedStops.add(new Stop<>(new CompositeValue<>(entry.getKey(), stop.in), stop.out));
|
||||
}
|
||||
}
|
||||
return flattenedStops;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private Map<Z, List<Stop<I, O>>> collect(
|
||||
@NonNull IterableStops<CompositeValue<Z, I>, O, Stop<CompositeValue<Z, I>, O>> stops) {
|
||||
Map<Z, List<Stop<I, O>>> converted = new HashMap<>();
|
||||
|
||||
for (Stop<CompositeValue<Z, I>, O> stop : stops) {
|
||||
List<Stop<I, O>> stopsForZ = converted.get(stop.in.zoom);
|
||||
if (stopsForZ == null) {
|
||||
stopsForZ = new ArrayList<>();
|
||||
converted.put(stop.in.zoom, stopsForZ);
|
||||
}
|
||||
|
||||
stopsForZ.add(new Stop<>(stop.in.value, stop.out));
|
||||
}
|
||||
|
||||
return converted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Map.Entry<Z, S>> iterator() {
|
||||
return stops.entrySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return stops.size();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
/**
|
||||
* The {@link Stops} implementation for identity functions
|
||||
*
|
||||
* @param <T> the input/output type
|
||||
*/
|
||||
public class IdentityStops<T> extends Stops<T, T> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String getTypeName() {
|
||||
return "identity";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
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 interval functions
|
||||
*
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
*/
|
||||
public class IntervalStops<I, O> extends IterableStops<I, O, Stop<I, O>> {
|
||||
|
||||
private final Stop<I, O>[] stops;
|
||||
|
||||
@SafeVarargs
|
||||
public IntervalStops(@NonNull @Size(min = 1) Stop<I, O>... stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return "interval";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> toValueObject() {
|
||||
Map<String, Object> map = super.toValueObject();
|
||||
map.put("stops", toValueObjects(stops));
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an {@link Iterator} for the contained stops
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Stop<I, O>> iterator() {
|
||||
return Arrays.asList(stops).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of contained stops
|
||||
*/
|
||||
@Override
|
||||
public int size() {
|
||||
return stops.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Base class for {@link Stops} implementations with a collection of stops
|
||||
*
|
||||
* @param <I> the {@link Stops} input type
|
||||
* @param <O> the {@link Stops} output type
|
||||
* @param <S> the {@link Iterable} element type (usually {@link Stop})
|
||||
*/
|
||||
public abstract class IterableStops<I, O, S> extends Stops<I, O> implements Iterable<S> {
|
||||
|
||||
/**
|
||||
* @return The size of the contained stops collection
|
||||
*/
|
||||
public abstract int size();
|
||||
|
||||
/**
|
||||
* Convenience function to toValueObjects an array of stops to an array of value objects
|
||||
*
|
||||
* @param stops the stops to toValueObjects
|
||||
* @return the stops as value objects
|
||||
*/
|
||||
Object[] toValueObjects(Stop<I, O>[] stops) {
|
||||
if (stops != null) {
|
||||
Object[] stopsValue = new Object[stops.length];
|
||||
|
||||
for (int i = 0; i < stopsValue.length; i++) {
|
||||
Stop stop = stops[i];
|
||||
stopsValue[i] = stop.toValueObject();
|
||||
}
|
||||
return stopsValue;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
Iterator<S> iterator = iterator();
|
||||
while (iterator.hasNext()) {
|
||||
S stop = iterator.next();
|
||||
buffer.append(stop);
|
||||
if (iterator.hasNext()) {
|
||||
buffer.append(",");
|
||||
}
|
||||
}
|
||||
return String.format("%s: [%s]", super.toString(), buffer.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A stop represents a certain point in the range of this function
|
||||
*
|
||||
* @param <I> input the stop (function) input type
|
||||
* @param <O> output the stop (function) output type
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a>
|
||||
*/
|
||||
public class Stop<I, O> {
|
||||
/**
|
||||
* Creates a {@link Stop} to use in a {@link Function}
|
||||
*
|
||||
* @param in the input for the stop
|
||||
* @param output the output for the stop
|
||||
* @param <I> the input property type
|
||||
* @param <O> the output property type
|
||||
* @return the {@link Stop}
|
||||
*/
|
||||
public static <I, O> Stop<I, O> stop(I in, PropertyValue<O> output) {
|
||||
return new Stop<>(in, output.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a composite {@link Stop} for use in a {@link com.mapbox.mapboxsdk.style.functions.CompositeFunction}
|
||||
*
|
||||
* @param zoom the zoom input
|
||||
* @param value the feature property input
|
||||
* @param output the output for the stop
|
||||
* @param <Z> the zoom type
|
||||
* @param <I> the feature property input type
|
||||
* @param <O> the output property type
|
||||
* @return the {@link Stop}
|
||||
* @see Function#composite(String, ExponentialStops)
|
||||
*/
|
||||
public static <Z extends Number, I, O> Stop<Stop.CompositeValue<Z, I>, O> stop(Z zoom,
|
||||
I value,
|
||||
PropertyValue<O> output) {
|
||||
return new Stop<>(new Stop.CompositeValue<>(zoom, value), output.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a composite input value for composite functions (eg zoom and feature property value)
|
||||
*
|
||||
* @param <Z> the zoom input type (typically Float)
|
||||
* @param <V> the feature property input type
|
||||
*/
|
||||
public static class CompositeValue<Z extends Number, V> {
|
||||
Z zoom;
|
||||
V value;
|
||||
|
||||
CompositeValue(Z zoom, V value) {
|
||||
this.zoom = zoom;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return the value object representation for core conversion
|
||||
*/
|
||||
Map<String, Object> toValueObject() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("zoom", zoom);
|
||||
map.put("value", value);
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[zoom: %s, value: %s]", zoom, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The input type
|
||||
*/
|
||||
public final I in;
|
||||
|
||||
/**
|
||||
* The output type
|
||||
*/
|
||||
public final O out;
|
||||
|
||||
Stop(I in, O out) {
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return an array representation of the Stop
|
||||
*/
|
||||
Object[] toValueObject() {
|
||||
return new Object[] {in instanceof CompositeValue ? ((CompositeValue) in).toValueObject() : in, out};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s, %s]", in, out);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The base class for different stops implementations
|
||||
*
|
||||
* @param <I> the input type
|
||||
* @param <O> the output type
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a>
|
||||
*/
|
||||
public abstract class Stops<I, O> {
|
||||
|
||||
/**
|
||||
* Convenience method for use in function declarations
|
||||
*
|
||||
* @param stops the collections of discrete stops
|
||||
* @param <I> the Stops input type
|
||||
* @param <O> the Stops output type
|
||||
* @return the {@link Stops} implementation
|
||||
* @see Stop#stop
|
||||
* @see CategoricalStops
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <I, O> CategoricalStops<I, O> categorical(@NonNull @Size(min = 1) Stop<I, O>... stops) {
|
||||
return new CategoricalStops<>(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for use in function declarations
|
||||
*
|
||||
* @param stops the collections of discrete stops
|
||||
* @param <I> the Stops input type
|
||||
* @param <O> the Stops output type
|
||||
* @return the {@link Stops} implementation
|
||||
* @see Stop#stop
|
||||
* @see ExponentialStops
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <I, O> ExponentialStops<I, O> exponential(@NonNull @Size(min = 1) Stop<I, O>... stops) {
|
||||
return new ExponentialStops<>(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for use in function declarations
|
||||
*
|
||||
* @param <T> the Stops input/output type
|
||||
* @return the {@link IdentityStops} implementation
|
||||
* @see Stop#stop
|
||||
* @see IdentityStops
|
||||
*/
|
||||
public static <T> IdentityStops<T> identity() {
|
||||
return new IdentityStops<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for use in function declarations
|
||||
*
|
||||
* @param stops the collections of discrete stops
|
||||
* @param <I> the Stops input type
|
||||
* @param <O> the Stops output type
|
||||
* @return the {@link Stops} implementation
|
||||
* @see Stop#stop
|
||||
* @see IntervalStops
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <I, O> IntervalStops<I, O> interval(@NonNull @Size(min = 1) Stop<I, O>... stops) {
|
||||
return new IntervalStops<>(stops);
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return the value object representation for conversion to core
|
||||
*/
|
||||
public Map<String, Object> toValueObject() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("type", getTypeName());
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* INTERNAL USAGE ONLY
|
||||
*
|
||||
* @return the unique type name as a string according to the style specification
|
||||
*/
|
||||
protected abstract String getTypeName();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getTypeName();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Contains the Mapbox Maps Android Style Function Stop implementation API classes.
|
||||
*
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a>
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.style.functions.stops;
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -41,7 +42,7 @@ public class BackgroundLayer extends Layer {
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public BackgroundLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public BackgroundLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ public class BackgroundLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getBackgroundColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundColor());
|
||||
return (PropertyValue<String>) new PropertyValue("background-color", nativeGetBackgroundColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,7 +83,7 @@ public class BackgroundLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getBackgroundPattern() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetBackgroundPattern());
|
||||
return (PropertyValue<String>) new PropertyValue("background-pattern", nativeGetBackgroundPattern());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,7 @@ public class BackgroundLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getBackgroundOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetBackgroundOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("background-opacity", nativeGetBackgroundOpacity());
|
||||
}
|
||||
|
||||
private native Object nativeGetBackgroundColor();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -96,14 +97,13 @@ public class CircleLayer extends Layer {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public CircleLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public CircleLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleRadius() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleRadius());
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-radius", nativeGetCircleRadius());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getCircleColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetCircleColor());
|
||||
return (PropertyValue<String>) new PropertyValue("circle-color", nativeGetCircleColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleBlur() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleBlur());
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-blur", nativeGetCircleBlur());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,7 +164,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-opacity", nativeGetCircleOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getCircleTranslate() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetCircleTranslate());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("circle-translate", nativeGetCircleTranslate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,7 +184,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getCircleTranslateAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetCircleTranslateAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("circle-translate-anchor", nativeGetCircleTranslateAnchor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getCirclePitchScale() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetCirclePitchScale());
|
||||
return (PropertyValue<String>) new PropertyValue("circle-pitch-scale", nativeGetCirclePitchScale());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleStrokeWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleStrokeWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-stroke-width", nativeGetCircleStrokeWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getCircleStrokeColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetCircleStrokeColor());
|
||||
return (PropertyValue<String>) new PropertyValue("circle-stroke-color", nativeGetCircleStrokeColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +241,7 @@ public class CircleLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getCircleStrokeOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetCircleStrokeOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("circle-stroke-opacity", nativeGetCircleStrokeOpacity());
|
||||
}
|
||||
|
||||
private native Object nativeGetCircleRadius();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -96,14 +97,13 @@ public class FillLayer extends Layer {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public FillLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public FillLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getFillAntialias() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetFillAntialias());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("fill-antialias", nativeGetFillAntialias());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getFillOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetFillOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("fill-opacity", nativeGetFillOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,12 +137,11 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getFillColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetFillColor());
|
||||
return (PropertyValue<String>) new PropertyValue("fill-color", nativeGetFillColor());
|
||||
}
|
||||
|
||||
/**
|
||||
* The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the
|
||||
* color's opacity will not affect the opacity of the 1px stroke, if it is used.
|
||||
* The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
@@ -165,7 +164,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getFillOutlineColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetFillOutlineColor());
|
||||
return (PropertyValue<String>) new PropertyValue("fill-outline-color", nativeGetFillOutlineColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +191,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getFillTranslate() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetFillTranslate());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("fill-translate", nativeGetFillTranslate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +201,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getFillTranslateAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetFillTranslateAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("fill-translate-anchor", nativeGetFillTranslateAnchor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +211,7 @@ public class FillLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getFillPattern() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetFillPattern());
|
||||
return (PropertyValue<String>) new PropertyValue("fill-pattern", nativeGetFillPattern());
|
||||
}
|
||||
|
||||
private native Object nativeGetFillAntialias();
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.Size;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Functions are used to change properties in relation to the state of the map.
|
||||
* <p>
|
||||
* Currently, only zoom functions are supported.
|
||||
* </p>
|
||||
*
|
||||
* @param <T> the target property's value type. Make sure it matches.
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The online documentation</a>
|
||||
*/
|
||||
public class Function<T> {
|
||||
|
||||
/**
|
||||
* A stop represents a certain point in the range of this function
|
||||
*
|
||||
* @param <I> input
|
||||
* @param <O> output
|
||||
*/
|
||||
public static class Stop<I, O> {
|
||||
public final I in;
|
||||
public final O out;
|
||||
|
||||
Stop(I in, O out) {
|
||||
this.in = in;
|
||||
this.out = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array representation of the Stop
|
||||
*/
|
||||
Object[] toValueObject() {
|
||||
return new Object[] {in, out};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s, %s]", in, out);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
|
||||
* Zoom functions can be used to create the illusion of depth and control data density.
|
||||
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
|
||||
*
|
||||
* @param stops the stops that define the function
|
||||
* @param <T> the property type
|
||||
* @return the {@link Function}
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Function<T> zoom(@NonNull @Size(min = 1) Stop<Float, T>... stops) {
|
||||
return new Function<T>(stops);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Zoom functions allow the appearance of a map feature to change with map’s zoom.
|
||||
* Zoom functions can be used to create the illusion of depth and control data density.
|
||||
* Each stop is an array with two elements, the first is a zoom and the second is a function output value.
|
||||
*
|
||||
* @param stops the stops that define the function
|
||||
* @param base the exponential base of the interpolation curve - Default 1
|
||||
* @param <T> the property type
|
||||
* @return the {@link Function}
|
||||
*/
|
||||
@SafeVarargs
|
||||
public static <T> Function<T> zoom(
|
||||
@FloatRange(from = 0, to = 1, fromInclusive = false, toInclusive = false) float base,
|
||||
@NonNull @Size(min = 1) Stop<Float, T>... stops) {
|
||||
return new Function<T>(stops)
|
||||
.withBase(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stop to use in a {@link Function}
|
||||
*
|
||||
* @param in the input for the stop
|
||||
* @param output the output for the stop
|
||||
* @param <T> the output property type
|
||||
* @return the {@link Stop}
|
||||
*/
|
||||
public static <T> Stop<Float, T> stop(float in, Property<T> output) {
|
||||
return new Stop<>(in, output.value);
|
||||
}
|
||||
|
||||
private final Stop<Float, T>[] stops;
|
||||
private Float base;
|
||||
|
||||
Function(@NonNull @Size(min = 1) Stop<Float, T>[] stops) {
|
||||
this.stops = stops;
|
||||
}
|
||||
|
||||
Function<T> withBase(float base) {
|
||||
this.base = base;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the base
|
||||
*/
|
||||
@Nullable
|
||||
public Float getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the stops in this function
|
||||
*/
|
||||
public Stop<Float, T>[] getStops() {
|
||||
return stops;
|
||||
}
|
||||
|
||||
Map<String, Object> toValueObject() {
|
||||
Object[] stopsValue = new Object[stops.length];
|
||||
|
||||
for (int i = 0; i < stopsValue.length; i++) {
|
||||
Stop stop = stops[i];
|
||||
stopsValue[i] = stop.toValueObject();
|
||||
}
|
||||
|
||||
Map<String, Object> value = new HashMap<>();
|
||||
if (base != null) {
|
||||
value.put("base", base);
|
||||
}
|
||||
value.put("stops", stopsValue);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
|
||||
/**
|
||||
* Base class for the different Layer types
|
||||
*/
|
||||
@@ -17,14 +19,14 @@ public abstract class Layer {
|
||||
public Layer() {
|
||||
}
|
||||
|
||||
public void setProperties(@NonNull Property<?>... properties) {
|
||||
public void setProperties(@NonNull PropertyValue<?>... properties) {
|
||||
if (properties.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Property<?> property : properties) {
|
||||
for (PropertyValue<?> property : properties) {
|
||||
Object converted = convertValue(property.value);
|
||||
if (property instanceof PaintProperty) {
|
||||
if (property instanceof PaintPropertyValue) {
|
||||
nativeSetPaintProperty(property.name, converted);
|
||||
} else {
|
||||
nativeSetLayoutProperty(property.name, converted);
|
||||
@@ -37,7 +39,7 @@ public abstract class Layer {
|
||||
}
|
||||
|
||||
public PropertyValue<String> getVisibility() {
|
||||
return new PropertyValue<>(nativeGetVisibility());
|
||||
return new PaintPropertyValue<>("visibility", (String) nativeGetVisibility());
|
||||
}
|
||||
|
||||
public float getMinZoom() {
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
class LayoutProperty<T> extends Property<T> {
|
||||
|
||||
LayoutProperty(String name, T value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
class LayoutPropertyValue<T> extends PropertyValue<T> {
|
||||
|
||||
LayoutPropertyValue(@NonNull String name, T value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -96,14 +97,13 @@ public class LineLayer extends Layer {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public LineLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public LineLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLineCap() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetLineCap());
|
||||
return (PropertyValue<String>) new PropertyValue("line-cap", nativeGetLineCap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLineJoin() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetLineJoin());
|
||||
return (PropertyValue<String>) new PropertyValue("line-join", nativeGetLineJoin());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineMiterLimit() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineMiterLimit());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-miter-limit", nativeGetLineMiterLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineRoundLimit() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineRoundLimit());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-round-limit", nativeGetLineRoundLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-opacity", nativeGetLineOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLineColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetLineColor());
|
||||
return (PropertyValue<String>) new PropertyValue("line-color", nativeGetLineColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +194,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getLineTranslate() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineTranslate());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("line-translate", nativeGetLineTranslate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLineTranslateAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetLineTranslateAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("line-translate-anchor", nativeGetLineTranslateAnchor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +214,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-width", nativeGetLineWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +224,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineGapWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineGapWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-gap-width", nativeGetLineGapWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,7 +234,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineOffset() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineOffset());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-offset", nativeGetLineOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,7 +244,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getLineBlur() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetLineBlur());
|
||||
return (PropertyValue<Float>) new PropertyValue("line-blur", nativeGetLineBlur());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +254,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getLineDasharray() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetLineDasharray());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("line-dasharray", nativeGetLineDasharray());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,7 +264,7 @@ public class LineLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getLinePattern() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetLinePattern());
|
||||
return (PropertyValue<String>) new PropertyValue("line-pattern", nativeGetLinePattern());
|
||||
}
|
||||
|
||||
private native Object nativeGetLineCap();
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
class PaintProperty<T> extends Property<T> {
|
||||
|
||||
PaintProperty(String name, T value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
class PaintPropertyValue<T> extends PropertyValue<T> {
|
||||
|
||||
PaintPropertyValue(@NonNull String name, T value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.StringDef;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -9,7 +10,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
/**
|
||||
* Paint/Layout properties for Layer
|
||||
*/
|
||||
public abstract class Property<T> {
|
||||
public final class Property {
|
||||
|
||||
// VISIBILITY: Whether this layer is displayed.
|
||||
|
||||
@@ -22,13 +23,12 @@ public abstract class Property<T> {
|
||||
*/
|
||||
public static final String NONE = "none";
|
||||
|
||||
@StringDef( {
|
||||
VISIBLE,
|
||||
NONE
|
||||
@StringDef({
|
||||
VISIBLE,
|
||||
NONE
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface VISIBILITY {
|
||||
}
|
||||
public @interface VISIBILITY {}
|
||||
|
||||
// LINE_CAP: The display of line endings.
|
||||
|
||||
@@ -37,57 +37,50 @@ public abstract class Property<T> {
|
||||
*/
|
||||
public static final String LINE_CAP_BUTT = "butt";
|
||||
/**
|
||||
* A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's
|
||||
* width and centered on the endpoint of the line.
|
||||
* A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
||||
*/
|
||||
public static final String LINE_CAP_ROUND = "round";
|
||||
/**
|
||||
* A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the
|
||||
* line's width.
|
||||
* A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
||||
*/
|
||||
public static final String LINE_CAP_SQUARE = "square";
|
||||
|
||||
/**
|
||||
* The display of line endings.
|
||||
*/
|
||||
@StringDef( {
|
||||
LINE_CAP_BUTT,
|
||||
LINE_CAP_ROUND,
|
||||
LINE_CAP_SQUARE,
|
||||
})
|
||||
@StringDef({
|
||||
LINE_CAP_BUTT,
|
||||
LINE_CAP_ROUND,
|
||||
LINE_CAP_SQUARE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LINE_CAP {
|
||||
}
|
||||
public @interface LINE_CAP {}
|
||||
|
||||
// LINE_JOIN: The display of lines when joining.
|
||||
|
||||
/**
|
||||
* A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the
|
||||
* line's width.
|
||||
* A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width.
|
||||
*/
|
||||
public static final String LINE_JOIN_BEVEL = "bevel";
|
||||
/**
|
||||
* A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's
|
||||
* width and centered on the endpoint of the line.
|
||||
* A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line.
|
||||
*/
|
||||
public static final String LINE_JOIN_ROUND = "round";
|
||||
/**
|
||||
* A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until
|
||||
* they meet.
|
||||
* A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet.
|
||||
*/
|
||||
public static final String LINE_JOIN_MITER = "miter";
|
||||
|
||||
/**
|
||||
* The display of lines when joining.
|
||||
*/
|
||||
@StringDef( {
|
||||
LINE_JOIN_BEVEL,
|
||||
LINE_JOIN_ROUND,
|
||||
LINE_JOIN_MITER,
|
||||
})
|
||||
@StringDef({
|
||||
LINE_JOIN_BEVEL,
|
||||
LINE_JOIN_ROUND,
|
||||
LINE_JOIN_MITER,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LINE_JOIN {
|
||||
}
|
||||
public @interface LINE_JOIN {}
|
||||
|
||||
// SYMBOL_PLACEMENT: Label placement relative to its geometry.
|
||||
|
||||
@@ -103,44 +96,38 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Label placement relative to its geometry.
|
||||
*/
|
||||
@StringDef( {
|
||||
SYMBOL_PLACEMENT_POINT,
|
||||
SYMBOL_PLACEMENT_LINE,
|
||||
})
|
||||
@StringDef({
|
||||
SYMBOL_PLACEMENT_POINT,
|
||||
SYMBOL_PLACEMENT_LINE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SYMBOL_PLACEMENT {
|
||||
}
|
||||
public @interface SYMBOL_PLACEMENT {}
|
||||
|
||||
// ICON_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of icons.
|
||||
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When
|
||||
* {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns icon x-axes with the line.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns icons east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns icon x-axes with the line.
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_MAP = "map";
|
||||
/**
|
||||
* Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of
|
||||
* {@link SYMBOL_PLACEMENT}.
|
||||
* Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}.
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to
|
||||
* {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to
|
||||
* {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#ICON_ROTATION_ALIGNMENT_MAP}.
|
||||
*/
|
||||
public static final String ICON_ROTATION_ALIGNMENT_AUTO = "auto";
|
||||
|
||||
/**
|
||||
* In combination with `symbol-placement`, determines the rotation behavior of icons.
|
||||
*/
|
||||
@StringDef( {
|
||||
ICON_ROTATION_ALIGNMENT_MAP,
|
||||
ICON_ROTATION_ALIGNMENT_VIEWPORT,
|
||||
ICON_ROTATION_ALIGNMENT_AUTO,
|
||||
})
|
||||
@StringDef({
|
||||
ICON_ROTATION_ALIGNMENT_MAP,
|
||||
ICON_ROTATION_ALIGNMENT_VIEWPORT,
|
||||
ICON_ROTATION_ALIGNMENT_AUTO,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ICON_ROTATION_ALIGNMENT {
|
||||
}
|
||||
public @interface ICON_ROTATION_ALIGNMENT {}
|
||||
|
||||
// ICON_TEXT_FIT: Scales the icon to fit around the associated text.
|
||||
|
||||
@@ -164,15 +151,14 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Scales the icon to fit around the associated text.
|
||||
*/
|
||||
@StringDef( {
|
||||
ICON_TEXT_FIT_NONE,
|
||||
ICON_TEXT_FIT_WIDTH,
|
||||
ICON_TEXT_FIT_HEIGHT,
|
||||
ICON_TEXT_FIT_BOTH,
|
||||
})
|
||||
@StringDef({
|
||||
ICON_TEXT_FIT_NONE,
|
||||
ICON_TEXT_FIT_WIDTH,
|
||||
ICON_TEXT_FIT_HEIGHT,
|
||||
ICON_TEXT_FIT_BOTH,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ICON_TEXT_FIT {
|
||||
}
|
||||
public @interface ICON_TEXT_FIT {}
|
||||
|
||||
// TEXT_PITCH_ALIGNMENT: Orientation of text when map is pitched.
|
||||
|
||||
@@ -192,46 +178,39 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Orientation of text when map is pitched.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_PITCH_ALIGNMENT_MAP,
|
||||
TEXT_PITCH_ALIGNMENT_VIEWPORT,
|
||||
TEXT_PITCH_ALIGNMENT_AUTO,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_PITCH_ALIGNMENT_MAP,
|
||||
TEXT_PITCH_ALIGNMENT_VIEWPORT,
|
||||
TEXT_PITCH_ALIGNMENT_AUTO,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_PITCH_ALIGNMENT {
|
||||
}
|
||||
public @interface TEXT_PITCH_ALIGNMENT {}
|
||||
|
||||
// TEXT_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of the individual
|
||||
// glyphs forming the text.
|
||||
// TEXT_ROTATION_ALIGNMENT: In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.
|
||||
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When
|
||||
* {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns text x-axes with the line.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, aligns text east-west. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, aligns text x-axes with the line.
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_MAP = "map";
|
||||
/**
|
||||
* Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of
|
||||
* {@link SYMBOL_PLACEMENT}.
|
||||
* Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of {@link SYMBOL_PLACEMENT}.
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_VIEWPORT = "viewport";
|
||||
/**
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to
|
||||
* {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to
|
||||
* {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}.
|
||||
* When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_POINT}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_VIEWPORT}. When {@link SYMBOL_PLACEMENT} is set to {@link Property#SYMBOL_PLACEMENT_LINE}, this is equivalent to {@link Property#TEXT_ROTATION_ALIGNMENT_MAP}.
|
||||
*/
|
||||
public static final String TEXT_ROTATION_ALIGNMENT_AUTO = "auto";
|
||||
|
||||
/**
|
||||
* In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_ROTATION_ALIGNMENT_MAP,
|
||||
TEXT_ROTATION_ALIGNMENT_VIEWPORT,
|
||||
TEXT_ROTATION_ALIGNMENT_AUTO,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_ROTATION_ALIGNMENT_MAP,
|
||||
TEXT_ROTATION_ALIGNMENT_VIEWPORT,
|
||||
TEXT_ROTATION_ALIGNMENT_AUTO,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_ROTATION_ALIGNMENT {
|
||||
}
|
||||
public @interface TEXT_ROTATION_ALIGNMENT {}
|
||||
|
||||
// TEXT_JUSTIFY: Text justification options.
|
||||
|
||||
@@ -251,14 +230,13 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Text justification options.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_JUSTIFY_LEFT,
|
||||
TEXT_JUSTIFY_CENTER,
|
||||
TEXT_JUSTIFY_RIGHT,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_JUSTIFY_LEFT,
|
||||
TEXT_JUSTIFY_CENTER,
|
||||
TEXT_JUSTIFY_RIGHT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_JUSTIFY {
|
||||
}
|
||||
public @interface TEXT_JUSTIFY {}
|
||||
|
||||
// TEXT_ANCHOR: Part of the text placed closest to the anchor.
|
||||
|
||||
@@ -302,20 +280,19 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Part of the text placed closest to the anchor.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_ANCHOR_CENTER,
|
||||
TEXT_ANCHOR_LEFT,
|
||||
TEXT_ANCHOR_RIGHT,
|
||||
TEXT_ANCHOR_TOP,
|
||||
TEXT_ANCHOR_BOTTOM,
|
||||
TEXT_ANCHOR_TOP_LEFT,
|
||||
TEXT_ANCHOR_TOP_RIGHT,
|
||||
TEXT_ANCHOR_BOTTOM_LEFT,
|
||||
TEXT_ANCHOR_BOTTOM_RIGHT,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_ANCHOR_CENTER,
|
||||
TEXT_ANCHOR_LEFT,
|
||||
TEXT_ANCHOR_RIGHT,
|
||||
TEXT_ANCHOR_TOP,
|
||||
TEXT_ANCHOR_BOTTOM,
|
||||
TEXT_ANCHOR_TOP_LEFT,
|
||||
TEXT_ANCHOR_TOP_RIGHT,
|
||||
TEXT_ANCHOR_BOTTOM_LEFT,
|
||||
TEXT_ANCHOR_BOTTOM_RIGHT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_ANCHOR {
|
||||
}
|
||||
public @interface TEXT_ANCHOR {}
|
||||
|
||||
// TEXT_TRANSFORM: Specifies how to capitalize text, similar to the CSS `text-transform` property.
|
||||
|
||||
@@ -335,14 +312,13 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Specifies how to capitalize text, similar to the CSS `text-transform` property.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_TRANSFORM_NONE,
|
||||
TEXT_TRANSFORM_UPPERCASE,
|
||||
TEXT_TRANSFORM_LOWERCASE,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_TRANSFORM_NONE,
|
||||
TEXT_TRANSFORM_UPPERCASE,
|
||||
TEXT_TRANSFORM_LOWERCASE,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_TRANSFORM {
|
||||
}
|
||||
public @interface TEXT_TRANSFORM {}
|
||||
|
||||
// FILL_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
|
||||
@@ -358,13 +334,12 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
*/
|
||||
@StringDef( {
|
||||
FILL_TRANSLATE_ANCHOR_MAP,
|
||||
FILL_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
FILL_TRANSLATE_ANCHOR_MAP,
|
||||
FILL_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FILL_TRANSLATE_ANCHOR {
|
||||
}
|
||||
public @interface FILL_TRANSLATE_ANCHOR {}
|
||||
|
||||
// LINE_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
|
||||
@@ -380,13 +355,12 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
*/
|
||||
@StringDef( {
|
||||
LINE_TRANSLATE_ANCHOR_MAP,
|
||||
LINE_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
LINE_TRANSLATE_ANCHOR_MAP,
|
||||
LINE_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LINE_TRANSLATE_ANCHOR {
|
||||
}
|
||||
public @interface LINE_TRANSLATE_ANCHOR {}
|
||||
|
||||
// ICON_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
|
||||
@@ -402,13 +376,12 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
*/
|
||||
@StringDef( {
|
||||
ICON_TRANSLATE_ANCHOR_MAP,
|
||||
ICON_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
ICON_TRANSLATE_ANCHOR_MAP,
|
||||
ICON_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ICON_TRANSLATE_ANCHOR {
|
||||
}
|
||||
public @interface ICON_TRANSLATE_ANCHOR {}
|
||||
|
||||
// TEXT_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
|
||||
@@ -424,13 +397,12 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
*/
|
||||
@StringDef( {
|
||||
TEXT_TRANSLATE_ANCHOR_MAP,
|
||||
TEXT_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
TEXT_TRANSLATE_ANCHOR_MAP,
|
||||
TEXT_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_TRANSLATE_ANCHOR {
|
||||
}
|
||||
public @interface TEXT_TRANSLATE_ANCHOR {}
|
||||
|
||||
// CIRCLE_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
|
||||
@@ -446,13 +418,12 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
*/
|
||||
@StringDef( {
|
||||
CIRCLE_TRANSLATE_ANCHOR_MAP,
|
||||
CIRCLE_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
CIRCLE_TRANSLATE_ANCHOR_MAP,
|
||||
CIRCLE_TRANSLATE_ANCHOR_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CIRCLE_TRANSLATE_ANCHOR {
|
||||
}
|
||||
public @interface CIRCLE_TRANSLATE_ANCHOR {}
|
||||
|
||||
// CIRCLE_PITCH_SCALE: Controls the scaling behavior of the circle when the map is pitched.
|
||||
|
||||
@@ -468,20 +439,14 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* Controls the scaling behavior of the circle when the map is pitched.
|
||||
*/
|
||||
@StringDef( {
|
||||
CIRCLE_PITCH_SCALE_MAP,
|
||||
CIRCLE_PITCH_SCALE_VIEWPORT,
|
||||
})
|
||||
@StringDef({
|
||||
CIRCLE_PITCH_SCALE_MAP,
|
||||
CIRCLE_PITCH_SCALE_VIEWPORT,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CIRCLE_PITCH_SCALE {
|
||||
}
|
||||
public @interface CIRCLE_PITCH_SCALE {}
|
||||
|
||||
// Class definition
|
||||
public final String name;
|
||||
public final T value;
|
||||
|
||||
/* package */ Property(String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
private Property() {
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,10 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
/**
|
||||
@@ -9,9 +12,11 @@ import timber.log.Timber;
|
||||
*/
|
||||
public class PropertyValue<T> {
|
||||
|
||||
private final Object value;
|
||||
public final String name;
|
||||
public final T value;
|
||||
|
||||
/* package */ PropertyValue(Object value) {
|
||||
/* package */ PropertyValue(@NonNull String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -28,10 +33,10 @@ public class PropertyValue<T> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Function<T> getFunction() {
|
||||
public Function<?, T> getFunction() {
|
||||
if (isFunction()) {
|
||||
// noinspection unchecked
|
||||
return (Function<T>) value;
|
||||
return (Function<?, T>) value;
|
||||
} else {
|
||||
Timber.w("not a function, try value");
|
||||
return null;
|
||||
@@ -51,7 +56,6 @@ public class PropertyValue<T> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%s)", getClass().getSimpleName(), value != null
|
||||
? value.getClass().getSimpleName() : null);
|
||||
return String.format("%s: %s", name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;
|
||||
|
||||
/**
|
||||
* Raster map textures such as satellite imagery.
|
||||
*
|
||||
@@ -59,7 +63,7 @@ public class RasterLayer extends Layer {
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public RasterLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public RasterLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -73,7 +77,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-opacity", nativeGetRasterOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +87,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterHueRotate() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterHueRotate());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-hue-rotate", nativeGetRasterHueRotate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +97,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterBrightnessMin() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMin());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-brightness-min", nativeGetRasterBrightnessMin());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,7 +107,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterBrightnessMax() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterBrightnessMax());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-brightness-max", nativeGetRasterBrightnessMax());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +117,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterSaturation() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterSaturation());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-saturation", nativeGetRasterSaturation());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +127,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterContrast() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterContrast());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-contrast", nativeGetRasterContrast());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -133,7 +137,7 @@ public class RasterLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getRasterFadeDuration() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetRasterFadeDuration());
|
||||
return (PropertyValue<Float>) new PropertyValue("raster-fade-duration", nativeGetRasterFadeDuration());
|
||||
}
|
||||
|
||||
private native Object nativeGetRasterOpacity();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -96,14 +97,13 @@ public class SymbolLayer extends Layer {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public SymbolLayer withProperties(@NonNull Property<?>... properties) {
|
||||
public SymbolLayer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getSymbolPlacement() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetSymbolPlacement());
|
||||
return (PropertyValue<String>) new PropertyValue("symbol-placement", nativeGetSymbolPlacement());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getSymbolSpacing() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetSymbolSpacing());
|
||||
return (PropertyValue<Float>) new PropertyValue("symbol-spacing", nativeGetSymbolSpacing());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getSymbolAvoidEdges() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetSymbolAvoidEdges());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("symbol-avoid-edges", nativeGetSymbolAvoidEdges());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getIconAllowOverlap() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconAllowOverlap());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("icon-allow-overlap", nativeGetIconAllowOverlap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getIconIgnorePlacement() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconIgnorePlacement());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("icon-ignore-placement", nativeGetIconIgnorePlacement());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getIconOptional() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconOptional());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("icon-optional", nativeGetIconOptional());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +177,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconRotationAlignment() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconRotationAlignment());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-rotation-alignment", nativeGetIconRotationAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconSize() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconSize());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-size", nativeGetIconSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,7 +197,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconTextFit() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconTextFit());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-text-fit", nativeGetIconTextFit());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,7 +207,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getIconTextFitPadding() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTextFitPadding());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("icon-text-fit-padding", nativeGetIconTextFitPadding());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +217,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconImage() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconImage());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-image", nativeGetIconImage());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +227,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconRotate() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconRotate());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-rotate", nativeGetIconRotate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -237,7 +237,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconPadding() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconPadding());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-padding", nativeGetIconPadding());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getIconKeepUpright() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetIconKeepUpright());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("icon-keep-upright", nativeGetIconKeepUpright());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +257,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getIconOffset() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconOffset());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("icon-offset", nativeGetIconOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +267,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextPitchAlignment() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextPitchAlignment());
|
||||
return (PropertyValue<String>) new PropertyValue("text-pitch-alignment", nativeGetTextPitchAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,7 +277,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextRotationAlignment() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextRotationAlignment());
|
||||
return (PropertyValue<String>) new PropertyValue("text-rotation-alignment", nativeGetTextRotationAlignment());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,7 +287,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextField() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextField());
|
||||
return (PropertyValue<String>) new PropertyValue("text-field", nativeGetTextField());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +297,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String[]> getTextFont() {
|
||||
return (PropertyValue<String[]>) new PropertyValue(nativeGetTextFont());
|
||||
return (PropertyValue<String[]>) new PropertyValue("text-font", nativeGetTextFont());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -307,7 +307,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextSize() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextSize());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-size", nativeGetTextSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,7 +317,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextMaxWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-max-width", nativeGetTextMaxWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +327,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextLineHeight() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLineHeight());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-line-height", nativeGetTextLineHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -337,7 +337,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextLetterSpacing() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextLetterSpacing());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-letter-spacing", nativeGetTextLetterSpacing());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +347,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextJustify() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextJustify());
|
||||
return (PropertyValue<String>) new PropertyValue("text-justify", nativeGetTextJustify());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +357,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("text-anchor", nativeGetTextAnchor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -367,7 +367,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextMaxAngle() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextMaxAngle());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-max-angle", nativeGetTextMaxAngle());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -377,7 +377,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextRotate() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextRotate());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-rotate", nativeGetTextRotate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +387,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextPadding() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextPadding());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-padding", nativeGetTextPadding());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,7 +397,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getTextKeepUpright() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextKeepUpright());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("text-keep-upright", nativeGetTextKeepUpright());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,7 +407,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextTransform() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextTransform());
|
||||
return (PropertyValue<String>) new PropertyValue("text-transform", nativeGetTextTransform());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +417,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getTextOffset() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextOffset());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("text-offset", nativeGetTextOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -427,7 +427,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getTextAllowOverlap() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextAllowOverlap());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("text-allow-overlap", nativeGetTextAllowOverlap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -437,7 +437,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getTextIgnorePlacement() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextIgnorePlacement());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("text-ignore-placement", nativeGetTextIgnorePlacement());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -447,7 +447,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Boolean> getTextOptional() {
|
||||
return (PropertyValue<Boolean>) new PropertyValue(nativeGetTextOptional());
|
||||
return (PropertyValue<Boolean>) new PropertyValue("text-optional", nativeGetTextOptional());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -457,7 +457,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-opacity", nativeGetIconOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,7 +467,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconColor());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-color", nativeGetIconColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -494,7 +494,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconHaloColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconHaloColor());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-halo-color", nativeGetIconHaloColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -521,7 +521,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconHaloWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-halo-width", nativeGetIconHaloWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -531,7 +531,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getIconHaloBlur() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetIconHaloBlur());
|
||||
return (PropertyValue<Float>) new PropertyValue("icon-halo-blur", nativeGetIconHaloBlur());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -541,7 +541,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getIconTranslate() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetIconTranslate());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("icon-translate", nativeGetIconTranslate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -551,7 +551,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getIconTranslateAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetIconTranslateAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("icon-translate-anchor", nativeGetIconTranslateAnchor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -561,7 +561,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextOpacity() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextOpacity());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-opacity", nativeGetTextOpacity());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -571,7 +571,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextColor());
|
||||
return (PropertyValue<String>) new PropertyValue("text-color", nativeGetTextColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,7 +598,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextHaloColor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextHaloColor());
|
||||
return (PropertyValue<String>) new PropertyValue("text-halo-color", nativeGetTextHaloColor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,7 +625,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextHaloWidth() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloWidth());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-halo-width", nativeGetTextHaloWidth());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -635,7 +635,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float> getTextHaloBlur() {
|
||||
return (PropertyValue<Float>) new PropertyValue(nativeGetTextHaloBlur());
|
||||
return (PropertyValue<Float>) new PropertyValue("text-halo-blur", nativeGetTextHaloBlur());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -645,7 +645,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<Float[]> getTextTranslate() {
|
||||
return (PropertyValue<Float[]>) new PropertyValue(nativeGetTextTranslate());
|
||||
return (PropertyValue<Float[]>) new PropertyValue("text-translate", nativeGetTextTranslate());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -655,7 +655,7 @@ public class SymbolLayer extends Layer {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<String> getTextTranslateAnchor() {
|
||||
return (PropertyValue<String>) new PropertyValue(nativeGetTextTranslateAnchor());
|
||||
return (PropertyValue<String>) new PropertyValue("text-translate-anchor", nativeGetTextTranslateAnchor());
|
||||
}
|
||||
|
||||
private native Object nativeGetSymbolPlacement();
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
const doc = locals.doc;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.UiThread;
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.UiThread;
|
||||
|
||||
import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
|
||||
import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;
|
||||
|
||||
/**
|
||||
* <%- doc %>
|
||||
@@ -21,151 +21,153 @@ import static com.mapbox.mapboxsdk.utils.ColorUtils.*;
|
||||
@UiThread
|
||||
public class <%- camelize(type) %>Layer extends Layer {
|
||||
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param nativePtr pointer used by core
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(long nativePtr) {
|
||||
super(nativePtr);
|
||||
}
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param nativePtr pointer used by core
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(long nativePtr) {
|
||||
super(nativePtr);
|
||||
}
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param layerId the id of the layer
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(String layerId) {
|
||||
initialize(layerId);
|
||||
}
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param layerId the id of the layer
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(String layerId) {
|
||||
initialize(layerId);
|
||||
}
|
||||
|
||||
protected native void initialize(String layerId);
|
||||
|
||||
protected native void initialize(String layerId);
|
||||
<% } else { -%>
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param layerId the id of the layer
|
||||
* @param sourceId the id of the source
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(String layerId, String sourceId) {
|
||||
initialize(layerId, sourceId);
|
||||
}
|
||||
/**
|
||||
* Creates a <%- camelize(type) %>Layer.
|
||||
*
|
||||
* @param layerId the id of the layer
|
||||
* @param sourceId the id of the source
|
||||
*/
|
||||
public <%- camelize(type) %>Layer(String layerId, String sourceId) {
|
||||
initialize(layerId, sourceId);
|
||||
}
|
||||
|
||||
protected native void initialize(String layerId, String sourceId);
|
||||
protected native void initialize(String layerId, String sourceId);
|
||||
|
||||
/**
|
||||
* Set the source layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
*/
|
||||
public void setSourceLayer(String sourceLayer) {
|
||||
nativeSetSourceLayer(sourceLayer);
|
||||
}
|
||||
/**
|
||||
* Set the source layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
*/
|
||||
public void setSourceLayer(String sourceLayer) {
|
||||
nativeSetSourceLayer(sourceLayer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source Layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withSourceLayer(String sourceLayer) {
|
||||
setSourceLayer(sourceLayer);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source Layer.
|
||||
*
|
||||
* @param sourceLayer the source layer to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withSourceLayer(String sourceLayer) {
|
||||
setSourceLayer(sourceLayer);
|
||||
return this;
|
||||
}
|
||||
<% } -%>
|
||||
<% if (type !== 'background' && type !== 'raster') { -%>
|
||||
/**
|
||||
* Set a single filter.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
*/
|
||||
public void setFilter(Filter.Statement filter) {
|
||||
this.setFilter(filter.toArray());
|
||||
}
|
||||
/**
|
||||
* Set a single filter.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
*/
|
||||
public void setFilter(Filter.Statement filter) {
|
||||
this.setFilter(filter.toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an array of filters.
|
||||
*
|
||||
* @param filter the filter array to set
|
||||
*/
|
||||
public void setFilter(Object[] filter) {
|
||||
nativeSetFilter(filter);
|
||||
}
|
||||
/**
|
||||
* Set an array of filters.
|
||||
*
|
||||
* @param filter the filter array to set
|
||||
*/
|
||||
public void setFilter(Object[] filter) {
|
||||
nativeSetFilter(filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an array of filters.
|
||||
*
|
||||
* @param filter tthe filter array to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withFilter(Object[] filter) {
|
||||
setFilter(filter);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Set an array of filters.
|
||||
*
|
||||
* @param filter tthe filter array to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withFilter(Object[] filter) {
|
||||
setFilter(filter);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a single filter.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withFilter(Filter.Statement filter) {
|
||||
setFilter(filter);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Set a single filter.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withFilter(Filter.Statement filter) {
|
||||
setFilter(filter);
|
||||
return this;
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withProperties(@NonNull PropertyValue<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property or properties.
|
||||
*
|
||||
* @param properties the var-args properties
|
||||
* @return This
|
||||
*/
|
||||
public <%- camelize(type) %>Layer withProperties(@NonNull Property<?>... properties) {
|
||||
setProperties(properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
// Property getters
|
||||
// Property getters
|
||||
|
||||
<% for (const property of properties) { -%>
|
||||
/**
|
||||
* Get the <%- camelize(property.name) %> property
|
||||
*
|
||||
* @return property wrapper value around <%- propertyType(property) %>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() {
|
||||
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue(nativeGet<%- camelize(property.name) %>());
|
||||
}
|
||||
<% if (property.type == 'color') { -%>
|
||||
/**
|
||||
* <%- property.doc %>
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int get<%- camelize(property.name) %>AsInt() {
|
||||
PropertyValue<<%- propertyType(property) %>> value = get<%- camelize(property.name) %>();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("<%- property.name %> was set as a Function");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the <%- camelize(property.name) %> property
|
||||
*
|
||||
* @return property wrapper value around <%- propertyType(property) %>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PropertyValue<<%- propertyType(property) %>> get<%- camelize(property.name) %>() {
|
||||
return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue("<%- property.name %>", nativeGet<%- camelize(property.name) %>());
|
||||
}
|
||||
<% if (property.type == 'color') { -%>
|
||||
|
||||
<% } -%>
|
||||
/**
|
||||
* <%- property.doc %>
|
||||
*
|
||||
* @return int representation of a rgba string color
|
||||
* @throws RuntimeException thrown if property isn't a value
|
||||
*/
|
||||
@ColorInt
|
||||
public int get<%- camelize(property.name) %>AsInt() {
|
||||
PropertyValue<<%- propertyType(property) %>> value = get<%- camelize(property.name) %>();
|
||||
if (value.isValue()) {
|
||||
return rgbaToColor(value.getValue());
|
||||
} else {
|
||||
throw new RuntimeException("<%- property.name %> was set as a Function");
|
||||
}
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
|
||||
<% } -%>
|
||||
<% for (const property of properties) { -%>
|
||||
private native Object nativeGet<%- camelize(property.name) %>();
|
||||
private native Object nativeGet<%- camelize(property.name) %>();
|
||||
|
||||
<% } -%>
|
||||
|
||||
@Override
|
||||
protected native void finalize() throws Throwable;
|
||||
@Override
|
||||
protected native void finalize() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
const properties = locals.properties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.StringDef;
|
||||
@@ -12,56 +13,49 @@ import java.lang.annotation.RetentionPolicy;
|
||||
/**
|
||||
* Paint/Layout properties for Layer
|
||||
*/
|
||||
public abstract class Property<T> {
|
||||
public final class Property {
|
||||
|
||||
// VISIBILITY: Whether this layer is displayed.
|
||||
// VISIBILITY: Whether this layer is displayed.
|
||||
|
||||
/**
|
||||
* The layer is shown.
|
||||
*/
|
||||
public static final String VISIBLE = "visible";
|
||||
/**
|
||||
* The layer is hidden.
|
||||
*/
|
||||
public static final String NONE = "none";
|
||||
/**
|
||||
* The layer is shown.
|
||||
*/
|
||||
public static final String VISIBLE = "visible";
|
||||
/**
|
||||
* The layer is hidden.
|
||||
*/
|
||||
public static final String NONE = "none";
|
||||
|
||||
@StringDef({
|
||||
VISIBLE,
|
||||
NONE
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface VISIBILITY {}
|
||||
@StringDef({
|
||||
VISIBLE,
|
||||
NONE
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface VISIBILITY {}
|
||||
|
||||
<% for (const property of properties) { -%>
|
||||
// <%- snakeCaseUpper(property.name) %>: <%- property.doc %>
|
||||
// <%- snakeCaseUpper(property.name) %>: <%- property.doc %>
|
||||
|
||||
<% for (const value in property.values) { -%>
|
||||
/**
|
||||
* <%- propertyValueDoc(property, value) %>
|
||||
*/
|
||||
public static final String <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %> = "<%- value %>";
|
||||
/**
|
||||
* <%- propertyValueDoc(property, value) %>
|
||||
*/
|
||||
public static final String <%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %> = "<%- value %>";
|
||||
<% } -%>
|
||||
|
||||
/**
|
||||
* <%- property.doc %>
|
||||
*/
|
||||
@StringDef({
|
||||
<% for (const value of Object.keys(property.values)) { -%>
|
||||
<%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %>,
|
||||
<% } -%>
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface <%- snakeCaseUpper(property.name) %> {}
|
||||
/**
|
||||
* <%- property.doc %>
|
||||
*/
|
||||
@StringDef({
|
||||
<% for (const value of Object.keys(property.values)) { -%>
|
||||
<%- snakeCaseUpper(property.name) %>_<%- snakeCaseUpper(value) %>,
|
||||
<% } -%>
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface <%- snakeCaseUpper(property.name) %> {}
|
||||
|
||||
<% } -%>
|
||||
|
||||
// Class definition
|
||||
public final String name;
|
||||
public final T value;
|
||||
|
||||
/* package */ Property(String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private Property() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
const layoutProperties = locals.layoutProperties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.support.annotation.ColorInt;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
|
||||
/**
|
||||
* Constructs paint/layout properties for Layers
|
||||
*
|
||||
@@ -15,85 +19,121 @@ import android.support.annotation.ColorInt;
|
||||
*/
|
||||
public class PropertyFactory {
|
||||
|
||||
/**
|
||||
* Set the property visibility.
|
||||
*
|
||||
* @param value the visibility value
|
||||
* @return property wrapper around visibility
|
||||
*/
|
||||
public static Property<String> visibility(@Property.VISIBILITY String value) {
|
||||
return new LayoutProperty<>("visibility", value);
|
||||
}
|
||||
/**
|
||||
* Set the property visibility.
|
||||
*
|
||||
* @param value the visibility value
|
||||
* @return property wrapper around visibility
|
||||
*/
|
||||
public static PropertyValue<String> visibility(@Property.VISIBILITY String value) {
|
||||
return new LayoutPropertyValue<>("visibility", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the property visibility.
|
||||
*
|
||||
* @param function the visibility function
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
public static Property<Function<String>> visibility(Function<String> function) {
|
||||
return new LayoutProperty<>("visibility", function);
|
||||
}
|
||||
/**
|
||||
* Set the property visibility.
|
||||
*
|
||||
* @param <T> the function input type
|
||||
* @param function the visibility function
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
public static <T> PropertyValue<Function<T, String>> visibility(Function<T, String> function) {
|
||||
return new LayoutPropertyValue<>("visibility", function);
|
||||
}
|
||||
|
||||
<% for (const property of paintProperties) { -%>
|
||||
<% if (property.type == 'color') { -%>
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
*/
|
||||
public static Property<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
|
||||
return new PaintProperty<>("<%- property.name %>", colorToRgbaString(value));
|
||||
}
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a int color value
|
||||
* @return property wrapper around String color
|
||||
*/
|
||||
public static PropertyValue<String> <%- camelizeWithLeadingLowercase(property.name) %>(@ColorInt int value) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", colorToRgbaString(value));
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a <%- propertyType(property) %> value
|
||||
* @return property wrapper around <%- propertyType(property) %>
|
||||
*/
|
||||
public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
|
||||
return new PaintProperty<>("<%- property.name %>", value);
|
||||
}
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a <%- propertyType(property) %> value
|
||||
* @return property wrapper around <%- propertyType(property) %>
|
||||
*/
|
||||
public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param function a wrapper function for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
|
||||
return new PaintProperty<>("<%- property.name %>", function);
|
||||
}
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param <T> the function input type
|
||||
* @param function a wrapper function for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
|
||||
<% } else if (supportsZoomFunction(property)) { -%>
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param <Z> the zoom parameter type
|
||||
* @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% for (const property of layoutProperties) { -%>
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a <%- propertyType(property) %> value
|
||||
* @return property wrapper around <%- propertyType(property) %>
|
||||
*/
|
||||
public static Property<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
|
||||
return new LayoutProperty<>("<%- property.name %>", value);
|
||||
}
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a <%- propertyType(property) %> value
|
||||
* @return property wrapper around <%- propertyType(property) %>
|
||||
*/
|
||||
public static PropertyValue<<%- propertyType(property) %>> <%- camelizeWithLeadingLowercase(property.name) %>(<%- propertyTypeAnnotation(property) %><%- iff(() => propertyTypeAnnotation(property), " ") %><%- propertyType(property) %> value) {
|
||||
return new LayoutPropertyValue<>("<%- property.name %>", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param function a wrapper function for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static Property<Function<<%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<<%- propertyType(property) %>> function) {
|
||||
return new LayoutProperty<>("<%- property.name %>", function);
|
||||
}
|
||||
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param <T> the function input type
|
||||
* @param function a wrapper function for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
|
||||
return new LayoutPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
|
||||
<% } else if (supportsZoomFunction(property)) { -%>
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param <Z> the zoom parameter type
|
||||
* @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
|
||||
return new LayoutPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
|
||||
<% } -%>
|
||||
@SuppressLint("DefaultLocale")
|
||||
static String colorToRgbaString(@ColorInt int value) {
|
||||
return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
|
||||
}
|
||||
<% } -%>
|
||||
@SuppressLint("DefaultLocale")
|
||||
public static String colorToRgbaString(@ColorInt int value) {
|
||||
return String.format("rgba(%d, %d, %d, %d)", (value >> 16) & 0xFF, (value >> 8) & 0xFF, value & 0xFF, (value >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ task checkstyle(type: Checkstyle) {
|
||||
source 'src'
|
||||
include '**/*.java'
|
||||
exclude '**/gen/**'
|
||||
exclude '**/style/*LayerTest.java'
|
||||
classpath = files()
|
||||
ignoreFailures = false
|
||||
}
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class BackgroundLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private BackgroundLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getBackgroundColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundColor(Color.RED));
|
||||
assertEquals(layer.getBackgroundColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getBackgroundPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(backgroundOpacity(0.3f));
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.BackgroundLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -18,16 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.backgroundPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for BackgroundLayer
|
||||
@@ -48,17 +57,16 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("visibility");
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -70,13 +78,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColor() {
|
||||
public void testBackgroundColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -86,13 +89,34 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsInt() {
|
||||
public void testBackgroundColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundColor());
|
||||
assertNotNull(layer.getBackgroundColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -102,13 +126,8 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundPattern() {
|
||||
public void testBackgroundPatternAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -118,13 +137,33 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacity() {
|
||||
public void testBackgroundPatternAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, backgroundPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundPattern());
|
||||
assertNotNull(layer.getBackgroundPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getBackgroundPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getBackgroundPattern().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -133,6 +172,32 @@ public class BackgroundLayerTest extends BaseStyleTest {
|
||||
assertEquals((Float) layer.getBackgroundOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackgroundOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("background-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
backgroundOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, backgroundOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getBackgroundOpacity());
|
||||
assertNotNull(layer.getBackgroundOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getBackgroundOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getBackgroundOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getBackgroundOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
@@ -1,265 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_PITCH_SCALE_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.CIRCLE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circlePitchScale;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for CircleLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CircleLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private CircleLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleRadius() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-radius");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleRadius(0.3f));
|
||||
assertEquals((Float) layer.getCircleRadius().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getCircleColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleColor(Color.RED));
|
||||
assertEquals(layer.getCircleColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleBlur(0.3f));
|
||||
assertEquals((Float) layer.getCircleBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleOpacity(0.3f));
|
||||
assertEquals((Float) layer.getCircleOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getCircleTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCircleTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circleTranslateAnchor(CIRCLE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getCircleTranslateAnchor().getValue(), (String) CIRCLE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCirclePitchScale() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new CircleLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("circle-pitch-scale");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(circlePitchScale(CIRCLE_PITCH_SCALE_MAP));
|
||||
assertEquals((String) layer.getCirclePitchScale().getValue(), (String) CIRCLE_PITCH_SCALE_MAP);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,286 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class FillLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private FillLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillAntialias(true));
|
||||
assertEquals((Boolean) layer.getFillAntialias().getValue(), (Boolean) true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOpacity(0.3f));
|
||||
assertEquals((Float) layer.getFillOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillColor(Color.RED));
|
||||
assertEquals(layer.getFillColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getFillOutlineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillOutlineColor(Color.RED));
|
||||
assertEquals(layer.getFillOutlineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getFillTranslateAnchor().getValue(), (String) FILL_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillPattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -18,21 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillPattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for FillLayer
|
||||
@@ -53,12 +57,6 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
@@ -69,7 +67,12 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -81,19 +84,8 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillAntialias() {
|
||||
public void testFillAntialiasAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -103,19 +95,33 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacity() {
|
||||
public void testFillAntialiasAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-antialias");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillAntialias(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillAntialias(true))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillAntialias());
|
||||
assertNotNull(layer.getFillAntialias().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillAntialias().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillAntialias().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillAntialias().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -125,19 +131,142 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColor() {
|
||||
public void testFillOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(property("FeaturePropertyA", Stops.<Float>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0.3f, fillOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop(1.0f, fillOpacity(0.3f))
|
||||
)
|
||||
).withDefaultValue(0.3f)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.3f, ((SourceFunction) layer.getFillOpacity().getFunction()).getDefaultValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOpacityAsCompositeFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, fillOpacity(0.9f))
|
||||
).withBase(0.5f)
|
||||
).withDefaultValue(0.3f)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOpacity());
|
||||
assertNotNull(layer.getFillOpacity().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.getFillOpacity().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.getFillOpacity().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.getFillOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.getFillOpacity().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>> stops =
|
||||
(CompositeStops<Float, Float, Float, ExponentialStops<Float, Float>>) layer.getFillOpacity().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<Float, Float>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -147,19 +276,105 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsInt() {
|
||||
public void testFillColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillColor(Color.RED))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillColor());
|
||||
assertNotNull(layer.getFillColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -169,19 +384,8 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColor() {
|
||||
public void testFillOutlineColorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -191,19 +395,105 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsInt() {
|
||||
public void testFillOutlineColorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillOutlineColor("rgba(0, 0, 0, 1)"))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillOutlineColor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(property("FeaturePropertyA", Stops.<String>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(Color.RED, fillOutlineColor(Color.RED))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillOutlineColor(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
stop("valueA", fillOutlineColor(Color.RED))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillOutlineColor());
|
||||
assertNotNull(layer.getFillOutlineColor().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.getFillOutlineColor().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.getFillOutlineColor().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.getFillOutlineColor().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillOutlineColorAsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-outline-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -213,41 +503,45 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslate() {
|
||||
public void testFillTranslateAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(fillTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
layer.setProperties(fillTranslate(new Float[]{0f,0f}));
|
||||
assertEquals((Float[]) layer.getFillTranslate().getValue(), (Float[]) new Float[]{0f,0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchor() {
|
||||
public void testFillTranslateAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, fillTranslate(new Float[]{0f,0f}))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslate());
|
||||
assertNotNull(layer.getFillTranslate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getFillTranslate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getFillTranslate().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillTranslateAnchorAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -257,19 +551,33 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPattern() {
|
||||
public void testFillTranslateAnchorAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillTranslateAnchor(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillTranslateAnchor(FILL_TRANSLATE_ANCHOR_MAP))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new FillLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getFillTranslateAnchor());
|
||||
assertNotNull(layer.getFillTranslateAnchor().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillTranslateAnchor().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillTranslateAnchor().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillTranslateAnchor().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPatternAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -278,6 +586,31 @@ public class FillLayerTest extends BaseStyleTest {
|
||||
assertEquals((String) layer.getFillPattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFillPatternAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("fill-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
fillPattern(
|
||||
zoom(
|
||||
interval(
|
||||
stop(2, fillPattern("pedestrian-polygon"))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getFillPattern());
|
||||
assertNotNull(layer.getFillPattern().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getFillPattern().getFunction().getClass());
|
||||
assertEquals(IntervalStops.class, layer.getFillPattern().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.getFillPattern().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_BUTT;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_JOIN_BEVEL;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.LINE_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineCap;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineDasharray;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineGapWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineJoin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineMiterLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOffset;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.linePattern;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineRoundLimit;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineTranslateAnchor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineWidth;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for LineLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class LineLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private LineLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineCap() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-cap");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineCap(LINE_CAP_BUTT));
|
||||
assertEquals((String) layer.getLineCap().getValue(), (String) LINE_CAP_BUTT);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineJoin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-join");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineJoin(LINE_JOIN_BEVEL));
|
||||
assertEquals((String) layer.getLineJoin().getValue(), (String) LINE_JOIN_BEVEL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineMiterLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-miter-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineMiterLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineMiterLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineRoundLimit() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-round-limit");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineRoundLimit(0.3f));
|
||||
assertEquals((Float) layer.getLineRoundLimit().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineOpacity(0.3f));
|
||||
assertEquals((Float) layer.getLineOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineColor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineColor("rgba(0, 0, 0, 1)"));
|
||||
assertEquals((String) layer.getLineColor().getValue(), (String) "rgba(0, 0, 0, 1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineColorAsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-color");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineColor(Color.RED));
|
||||
assertEquals(layer.getLineColorAsInt(), Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineTranslate(new Float[] {0f, 0f}));
|
||||
assertEquals((Float[]) layer.getLineTranslate().getValue(), (Float[]) new Float[] {0f, 0f});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineTranslateAnchor() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-translate-anchor");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineTranslateAnchor(LINE_TRANSLATE_ANCHOR_MAP));
|
||||
assertEquals((String) layer.getLineTranslateAnchor().getValue(), (String) LINE_TRANSLATE_ANCHOR_MAP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineGapWidth() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-gap-width");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineGapWidth(0.3f));
|
||||
assertEquals((Float) layer.getLineGapWidth().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineOffset() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-offset");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineOffset(0.3f));
|
||||
assertEquals((Float) layer.getLineOffset().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineBlur() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-blur");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineBlur(0.3f));
|
||||
assertEquals((Float) layer.getLineBlur().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineDasharray() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-dasharray");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(lineDasharray(new Float[] {}));
|
||||
assertEquals((Float[]) layer.getLineDasharray().getValue(), (Float[]) new Float[] {});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLinePattern() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new LineLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("line-pattern");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(linePattern("pedestrian-polygon"));
|
||||
assertEquals((String) layer.getLinePattern().getValue(), (String) "pedestrian-polygon");
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,240 +0,0 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make style-code-android`.
|
||||
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
import com.mapbox.mapboxsdk.testapp.utils.OnMapReadyIdlingResource;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class RasterLayerStyleTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private RasterLayer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterOpacity(0.3f));
|
||||
assertEquals((Float) layer.getRasterOpacity().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterHueRotate(0.3f));
|
||||
assertEquals((Float) layer.getRasterHueRotate().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMin(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMin().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterBrightnessMax(0.3f));
|
||||
assertEquals((Float) layer.getRasterBrightnessMax().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterSaturation(0.3f));
|
||||
assertEquals((Float) layer.getRasterSaturation().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterContrast(0.3f));
|
||||
assertEquals((Float) layer.getRasterContrast().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(rasterFadeDuration(0.3f));
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,23 @@
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.RasterLayer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -17,20 +29,14 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import timber.log.Timber;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMax;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterBrightnessMin;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterContrast;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterFadeDuration;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterHueRotate;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.rasterSaturation;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
|
||||
/**
|
||||
* Basic smoke tests for RasterLayer
|
||||
@@ -51,12 +57,6 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
@@ -67,7 +67,12 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("visibility");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
@@ -79,19 +84,8 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterOpacity() {
|
||||
public void testRasterOpacityAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -101,19 +95,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotate() {
|
||||
public void testRasterOpacityAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-opacity");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterOpacity(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterOpacity(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterOpacity());
|
||||
assertNotNull(layer.getRasterOpacity().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterOpacity().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterOpacity().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterOpacity().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterHueRotateAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -123,19 +132,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMin() {
|
||||
public void testRasterHueRotateAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-hue-rotate");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterHueRotate(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterHueRotate(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterHueRotate());
|
||||
assertNotNull(layer.getRasterHueRotate().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterHueRotate().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterHueRotate().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterHueRotate().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMinAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -145,19 +169,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMax() {
|
||||
public void testRasterBrightnessMinAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-min");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMin(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMin(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMin());
|
||||
assertNotNull(layer.getRasterBrightnessMin().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMin().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMin().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMin().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterBrightnessMaxAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -167,19 +206,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturation() {
|
||||
public void testRasterBrightnessMaxAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-brightness-max");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterBrightnessMax(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterBrightnessMax(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterBrightnessMax());
|
||||
assertNotNull(layer.getRasterBrightnessMax().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterBrightnessMax().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterBrightnessMax().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterBrightnessMax().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterSaturationAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -189,19 +243,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrast() {
|
||||
public void testRasterSaturationAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-saturation");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterSaturation(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterSaturation(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterSaturation());
|
||||
assertNotNull(layer.getRasterSaturation().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterSaturation().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterSaturation().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterSaturation().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterContrastAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -211,19 +280,34 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDuration() {
|
||||
public void testRasterContrastAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-contrast");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterContrast(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterContrast(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new RasterLayer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterContrast());
|
||||
assertNotNull(layer.getRasterContrast().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterContrast().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterContrast().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterContrast().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDurationAsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
@@ -232,6 +316,32 @@ public class RasterLayerTest extends BaseStyleTest {
|
||||
assertEquals((Float) layer.getRasterFadeDuration().getValue(), (Float) 0.3f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRasterFadeDurationAsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("raster-fade-duration");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
rasterFadeDuration(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(2, rasterFadeDuration(0.3f))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.getRasterFadeDuration());
|
||||
assertNotNull(layer.getRasterFadeDuration().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.getRasterFadeDuration().getFunction().getClass());
|
||||
assertEquals(ExponentialStops.class, layer.getRasterFadeDuration().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.getRasterFadeDuration().getFunction().getStops()).size());
|
||||
}
|
||||
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@
|
||||
const properties = locals.properties;
|
||||
-%>
|
||||
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
|
||||
|
||||
package com.mapbox.mapboxsdk.testapp.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
@@ -12,6 +13,15 @@ import android.support.test.runner.AndroidJUnit4;
|
||||
import timber.log.Timber;
|
||||
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.style.functions.CompositeFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.SourceFunction;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CategoricalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.CompositeStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IdentityStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.<%- camelize(type) %>Layer;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
import com.mapbox.mapboxsdk.testapp.activity.style.RuntimeStyleTestActivity;
|
||||
@@ -23,6 +33,11 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.*;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.*;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@@ -33,112 +48,310 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class <%- camelize(type) %>LayerTest extends BaseStyleTest {
|
||||
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
@Rule
|
||||
public final ActivityTestRule<RuntimeStyleTestActivity> rule = new ActivityTestRule<>(RuntimeStyleTestActivity.class);
|
||||
|
||||
private <%- camelize(type) %>Layer layer;
|
||||
private <%- camelize(type) %>Layer layer;
|
||||
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
private OnMapReadyIdlingResource idlingResource;
|
||||
|
||||
private MapboxMap mapboxMap;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
@Before
|
||||
public void setup() {
|
||||
idlingResource = new OnMapReadyIdlingResource(rule.getActivity());
|
||||
Espresso.registerIdlingResources(idlingResource);
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Timber.i("visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetVisibility() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("Visibility");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Get initial
|
||||
assertEquals(layer.getVisibility().getValue(), VISIBLE);
|
||||
|
||||
// Set
|
||||
layer.setProperties(visibility(NONE));
|
||||
assertEquals(layer.getVisibility().getValue(), NONE);
|
||||
}
|
||||
|
||||
<% for (const property of properties) { -%>
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
<% if (supportsZoomFunction(property)) { -%>
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCameraFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
zoom(
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
interval(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
exponential(
|
||||
stop(2, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
).withBase(0.5f)
|
||||
<% } -%>
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>));
|
||||
assertEquals((<%- propertyType(property) %>) layer.get<%- camelize(property.name) %>().getValue(), (<%- propertyType(property) %>) <%- defaultValueJava(property) %>);
|
||||
}
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CameraFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((IntervalStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } else { -%>
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(0.5f, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).getBase(), 0.001);
|
||||
assertEquals(1, ((ExponentialStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
<% } -%>
|
||||
}
|
||||
<% } -%>
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIdentitySourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(property("FeaturePropertyA", Stops.<<%- propertyType(property) %>>identity()))
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% if (property.function == 'piecewise-constant') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IdentityStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% } else if (property.type === 'array') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntervalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
interval(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(1, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(IntervalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
<% } else { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsExponentialSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop(Color.RED, <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
<% } else {-%>
|
||||
stop(<%- defaultValueJava(property) %>, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
<% } -%>
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(ExponentialStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCategoricalSourceFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
property(
|
||||
"FeaturePropertyA",
|
||||
categorical(
|
||||
<% if (property.type == 'color') { -%>
|
||||
stop("valueA", <%- camelizeWithLeadingLowercase(property.name) %>(Color.RED))
|
||||
)
|
||||
)
|
||||
<% } else {-%>
|
||||
stop(1.0f, <%- camelizeWithLeadingLowercase(property.name) %>(<%- defaultValueJava(property) %>))
|
||||
)
|
||||
).withDefaultValue(<%- defaultValueJava(property) %>)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(SourceFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CategoricalStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
<% if (property.type !== 'color') { -%>
|
||||
assertEquals(<%- defaultValueJava(property) %>, ((SourceFunction) layer.get<%- camelize(property.name) %>().getFunction()).getDefaultValue());
|
||||
<% } -%>
|
||||
}
|
||||
<% if (property.type !== 'color') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsCompositeFunction() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set
|
||||
layer.setProperties(
|
||||
<%- camelizeWithLeadingLowercase(property.name) %>(
|
||||
composite(
|
||||
"FeaturePropertyA",
|
||||
exponential(
|
||||
stop(0, 0.3f, <%- camelizeWithLeadingLowercase(property.name) %>(0.9f))
|
||||
).withBase(0.5f)
|
||||
<% if (property.type == 'number') { -%>
|
||||
).withDefaultValue(<%- defaultValueJava(property) %>)
|
||||
<% } else { -%>
|
||||
)
|
||||
<% } -%>
|
||||
)
|
||||
);
|
||||
|
||||
// Verify
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>());
|
||||
assertNotNull(layer.get<%- camelize(property.name) %>().getFunction());
|
||||
assertEquals(CompositeFunction.class, layer.get<%- camelize(property.name) %>().getFunction().getClass());
|
||||
assertEquals("FeaturePropertyA", ((CompositeFunction) layer.get<%- camelize(property.name) %>().getFunction()).getProperty());
|
||||
assertEquals(CompositeStops.class, layer.get<%- camelize(property.name) %>().getFunction().getStops().getClass());
|
||||
assertEquals(1, ((CompositeStops) layer.get<%- camelize(property.name) %>().getFunction().getStops()).size());
|
||||
|
||||
CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stops =
|
||||
(CompositeStops<Float, <%- propertyType(property) %>, <%- propertyType(property) %>, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>>) layer.get<%- camelize(property.name) %>().getFunction().getStops();
|
||||
Map.Entry<Float, ExponentialStops<<%- propertyType(property) %>, <%- propertyType(property) %>>> stop = stops.iterator().next();
|
||||
assertEquals(ExponentialStops.class, stop.getValue().getClass());
|
||||
assertEquals(0f, stop.getKey(), 0.001);
|
||||
assertEquals(1, stop.getValue().size());
|
||||
assertEquals(0.3f, stop.getValue().iterator().next().in, 0.001f);
|
||||
assertEquals(0.9f, stop.getValue().iterator().next().out, 0.001f);
|
||||
}
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% } -%>
|
||||
<% if (property.type == 'color') { -%>
|
||||
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsInt() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
@Test
|
||||
public void test<%- camelize(property.name) %>AsIntConstant() {
|
||||
checkViewIsDisplayed(R.id.mapView);
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
mapboxMap = rule.getActivity().getMapboxMap();
|
||||
|
||||
<% if (type === 'background') { -%>
|
||||
Timber.i("Retrieving layer");
|
||||
layer = mapboxMap.getLayerAs("background");
|
||||
<% } else { -%>
|
||||
if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
|
||||
Timber.i("Adding layer");
|
||||
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
|
||||
layer.setSourceLayer("composite");
|
||||
mapboxMap.addLayer(layer);
|
||||
// Layer reference is now stale, get new reference
|
||||
layer = mapboxMap.getLayerAs("my-layer");
|
||||
}
|
||||
<% } -%>
|
||||
Timber.i("<%- property.name %>");
|
||||
assertNotNull(layer);
|
||||
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
// Set and Get
|
||||
layer.setProperties(<%- camelizeWithLeadingLowercase(property.name) %>(Color.RED));
|
||||
assertEquals(layer.get<%- camelize(property.name) %>AsInt(), Color.RED);
|
||||
}
|
||||
<% } -%>
|
||||
|
||||
<% } -%>
|
||||
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
@After
|
||||
public void unregisterIntentServiceIdlingResource() {
|
||||
Espresso.unregisterIdlingResources(idlingResource);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +406,17 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.DataDrivenStyleActivity"
|
||||
android:description="@string/description_data_driven_style"
|
||||
android:label="@string/activity_data_driven_style">
|
||||
<meta-data
|
||||
android:name="@string/category"
|
||||
android:value="@string/category_style"/>
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".activity.FeatureOverviewActivity"/>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.style.CircleLayerActivity"
|
||||
android:description="@string/description_circle_layer"
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
package com.mapbox.mapboxsdk.testapp.activity.style;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.RawRes;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.composite;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.property;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.categorical;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillAntialias;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillColor;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOpacity;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillOutlineColor;
|
||||
|
||||
/**
|
||||
* Sample Activity to show off the data driven runtime style api
|
||||
*/
|
||||
public class DataDrivenStyleActivity extends AppCompatActivity {
|
||||
|
||||
public static final String AMSTERDAM_PARKS_LAYER = "amsterdam-parks-layer";
|
||||
private MapView mapView;
|
||||
private MapboxMap mapboxMap;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_data_driven_style);
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = (MapView) findViewById(R.id.mapView);
|
||||
mapView.onCreate(savedInstanceState);
|
||||
|
||||
|
||||
mapView.getMapAsync(new OnMapReadyCallback() {
|
||||
@Override
|
||||
public void onMapReady(MapboxMap map) {
|
||||
// Store for later
|
||||
mapboxMap = map;
|
||||
|
||||
// Add a parks layer
|
||||
addParksLayer();
|
||||
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 14));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_data_driven_style, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
mapView.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mapView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mapView.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
mapView.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mapView.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
mapView.onLowMemory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_add_exponential_zoom_function:
|
||||
addExponentialZoomFunction();
|
||||
return true;
|
||||
case R.id.action_add_interval_zoom_function:
|
||||
addIntervalZoomFunction();
|
||||
return true;
|
||||
case R.id.action_add_categorical_source_function:
|
||||
addCategoricalSourceFunction();
|
||||
return true;
|
||||
case R.id.action_add_exponential_source_function:
|
||||
addExponentialSourceFunction();
|
||||
return true;
|
||||
case R.id.action_add_identity_source_function:
|
||||
addIdentitySourceFunction();
|
||||
return true;
|
||||
case R.id.action_add_interval_source_function:
|
||||
addIntervalSourceFunction();
|
||||
return true;
|
||||
case R.id.action_add_composite_categorical_function:
|
||||
addCompositeCategoricalFunction();
|
||||
return true;
|
||||
case R.id.action_add_composite_exponential_function:
|
||||
addCompositeExponentialFunction();
|
||||
return true;
|
||||
case R.id.action_add_composite_interval_function:
|
||||
addCompositeIntervalFunction();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addExponentialZoomFunction() {
|
||||
Timber.i("Add exponential zoom function");
|
||||
FillLayer layer = mapboxMap.getLayerAs("water");
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(1, fillColor(Color.RED)),
|
||||
stop(5, fillColor(Color.BLUE)),
|
||||
stop(10, fillColor(Color.GREEN))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addIntervalZoomFunction() {
|
||||
Timber.i("Add interval zoom function");
|
||||
FillLayer layer = mapboxMap.getLayerAs("water");
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
zoom(
|
||||
interval(
|
||||
stop(1, fillColor(Color.RED)),
|
||||
stop(5, fillColor(Color.BLUE)),
|
||||
stop(10, fillColor(Color.GREEN))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addExponentialSourceFunction() {
|
||||
Timber.i("Add exponential source function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"stroke-width",
|
||||
exponential(
|
||||
stop(1f, fillColor(Color.RED)),
|
||||
stop(5f, fillColor(Color.BLUE)),
|
||||
stop(10f, fillColor(Color.GREEN))
|
||||
).withBase(0.5f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addCategoricalSourceFunction() {
|
||||
Timber.i("Add categorical source function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"name",
|
||||
categorical(
|
||||
stop("Westerpark", fillColor(Color.RED)),
|
||||
stop("Jordaan", fillColor(Color.BLUE)),
|
||||
stop("Prinseneiland", fillColor(Color.GREEN))
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addIdentitySourceFunction() {
|
||||
Timber.i("Add identity source function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillOpacity(
|
||||
property(
|
||||
"fill-opacity",
|
||||
Stops.<Float>identity())
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill opacity: %s", layer.getFillOpacity());
|
||||
}
|
||||
|
||||
private void addIntervalSourceFunction() {
|
||||
Timber.i("Add interval source function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
property(
|
||||
"stroke-width",
|
||||
interval(
|
||||
stop(1f, fillColor(Color.RED)),
|
||||
stop(5f, fillColor(Color.BLUE)),
|
||||
stop(10f, fillColor(Color.GREEN))
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addCompositeExponentialFunction() {
|
||||
Timber.i("Add composite exponential function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
composite(
|
||||
"stroke-width",
|
||||
exponential(
|
||||
stop(1, 1, fillColor(Color.RED)),
|
||||
stop(10, 2, fillColor(Color.BLUE)),
|
||||
stop(22, 3, fillColor(Color.GREEN)),
|
||||
stop(1, 1, fillColor(Color.CYAN)),
|
||||
stop(10, 2, fillColor(Color.GRAY)),
|
||||
stop(22, 3, fillColor(Color.YELLOW))
|
||||
).withBase(1f)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addCompositeIntervalFunction() {
|
||||
Timber.i("Add composite exponential function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
composite(
|
||||
"stroke-width",
|
||||
interval(
|
||||
stop(1, 1, fillColor(Color.RED)),
|
||||
stop(10, 2, fillColor(Color.BLUE)),
|
||||
stop(22, 3, fillColor(Color.GREEN)),
|
||||
stop(1, 1, fillColor(Color.CYAN)),
|
||||
stop(10, 2, fillColor(Color.GRAY)),
|
||||
stop(22, 3, fillColor(Color.YELLOW))
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addCompositeCategoricalFunction() {
|
||||
Timber.i("Add composite categorical function");
|
||||
FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
|
||||
assert layer != null;
|
||||
layer.setProperties(
|
||||
fillColor(
|
||||
composite(
|
||||
"name",
|
||||
categorical(
|
||||
stop(7f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(8f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(9f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(10f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(11f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(12f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(13f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(14f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(15f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(16f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(17f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(18f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(19f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(20f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(21f, "Westerpark", fillColor(Color.RED)),
|
||||
stop(22f, "Westerpark", fillColor(Color.BLUE)),
|
||||
stop(14f, "Jordaan", fillColor(Color.GREEN)),
|
||||
stop(18f, "Jordaan", fillColor(Color.CYAN)),
|
||||
stop(14f, "Prinseneiland", fillColor(Color.WHITE)),
|
||||
stop(18f, "Prinseneiland", fillColor(Color.BLACK))
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
Timber.i("Fill color: %s", layer.getFillColor());
|
||||
}
|
||||
|
||||
private void addParksLayer() {
|
||||
// Add a source
|
||||
Source source;
|
||||
try {
|
||||
source = new GeoJsonSource("amsterdam-parks-source", readRawResource(R.raw.amsterdam));
|
||||
mapboxMap.addSource(source);
|
||||
} catch (IOException ioException) {
|
||||
Toast.makeText(
|
||||
DataDrivenStyleActivity.this,
|
||||
"Couldn't add source: " + ioException.getMessage(),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Add a fill layer
|
||||
mapboxMap.addLayer(new FillLayer(AMSTERDAM_PARKS_LAYER, source.getId())
|
||||
.withProperties(
|
||||
fillColor(Color.BLACK),
|
||||
fillOutlineColor(Color.BLUE),
|
||||
fillAntialias(true)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private String readRawResource(@RawRes int rawResource) throws IOException {
|
||||
InputStream is = getResources().openRawResource(rawResource);
|
||||
Writer writer = new StringWriter();
|
||||
char[] buffer = new char[1024];
|
||||
try {
|
||||
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
int numRead;
|
||||
while ((numRead = reader.read(buffer)) != -1) {
|
||||
writer.write(buffer, 0, numRead);
|
||||
}
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
|
||||
return writer.toString();
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,10 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.layers.FillLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.Function;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.layers.LineLayer;
|
||||
import com.mapbox.mapboxsdk.style.layers.NoSuchLayerException;
|
||||
@@ -43,13 +45,13 @@ import java.util.List;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.all;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Filter.lt;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Function.Stop;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Function.stop;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.FILL_TRANSLATE_ANCHOR_MAP;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Property.SYMBOL_PLACEMENT_POINT;
|
||||
@@ -412,23 +414,28 @@ public class RuntimeStyleActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
// Set a zoom function to update the color of the water
|
||||
layer.setProperties(fillColor(zoom(0.8f,
|
||||
stop(1, fillColor(Color.GREEN)),
|
||||
stop(4, fillColor(Color.BLUE)),
|
||||
stop(12, fillColor(Color.RED)),
|
||||
stop(20, fillColor(Color.BLACK))
|
||||
)));
|
||||
layer.setProperties(fillColor(
|
||||
zoom(
|
||||
exponential(
|
||||
stop(1, fillColor(Color.GREEN)),
|
||||
stop(4, fillColor(Color.BLUE)),
|
||||
stop(12, fillColor(Color.RED)),
|
||||
stop(20, fillColor(Color.BLACK))
|
||||
).withBase(0.8f)
|
||||
)
|
||||
));
|
||||
|
||||
// do some animations to show it off properly
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1), 1500);
|
||||
|
||||
PropertyValue<String> fillColor = layer.getFillColor();
|
||||
Function<String> function = fillColor.getFunction();
|
||||
Function<Float, String> function = (Function<Float, String>) fillColor.getFunction();
|
||||
if (function != null) {
|
||||
Timber.d("Fill color base: " + function.getBase());
|
||||
Timber.d("Fill color #stops: " + function.getStops().length);
|
||||
ExponentialStops<Float, String> stops = (ExponentialStops) function.getStops();
|
||||
Timber.d("Fill color base: " + stops.getBase());
|
||||
Timber.d("Fill color #stops: " + stops.size());
|
||||
if (function.getStops() != null) {
|
||||
for (Stop stop : function.getStops()) {
|
||||
for (Stop<Float, String> stop : stops) {
|
||||
Timber.d("Fill color #stops: " + stop);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mapbox.mapboxsdk.maps.MapView
|
||||
android:id="@id/mapView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:mapbox="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_exponential_zoom_function"
|
||||
android:title="Add an exponential zoom function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_interval_zoom_function"
|
||||
android:title="Add an interval zoom function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_categorical_source_function"
|
||||
android:title="Add a categorical source function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_exponential_source_function"
|
||||
android:title="Add an exponential source function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_identity_source_function"
|
||||
android:title="Add an identity source function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_interval_source_function"
|
||||
android:title="Add an interval source function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_composite_exponential_function"
|
||||
android:title="Add a composite, exponential function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_composite_categorical_function"
|
||||
android:title="Add a composite, categorical function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add_composite_interval_function"
|
||||
android:title="Add a composite, interval function"
|
||||
mapbox:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
@@ -256,7 +256,7 @@
|
||||
"stroke-width": 2,
|
||||
"stroke-opacity": 1,
|
||||
"fill": "#555555",
|
||||
"fill-opacity": 0.5,
|
||||
"fill-opacity": 1.0,
|
||||
"name": "Sarphatipark",
|
||||
"type": "park",
|
||||
"description": "Sarphatipark is a small park in the popular De Pijp neighbourhood. It was openend in late 19th century, and named after Samuel Sarphati."
|
||||
@@ -482,7 +482,7 @@
|
||||
"stroke-width": 2,
|
||||
"stroke-opacity": 1,
|
||||
"fill": "#555555",
|
||||
"fill-opacity": 0.5,
|
||||
"fill-opacity": 0.1,
|
||||
"name": "Sloterdijk",
|
||||
"type": "area",
|
||||
"description": "To protect the area around Sloten from the as-yet undrained IJ the Spaarndammerdijk was laid along the south bank of this inlet. In this vicinity at the same time, a dam on the Slochter (or Slooter) river was built, the Slooterdam. Trade grew in the vicinity, and in the 15th century a weigh house and a church were built. The area is nowadays best known as a large intersection of train lines and a business and industrial centre north-west of Amsterdam."
|
||||
@@ -574,7 +574,7 @@
|
||||
"stroke-width": 2,
|
||||
"stroke-opacity": 1,
|
||||
"fill": "#555555",
|
||||
"fill-opacity": 0.5,
|
||||
"fill-opacity": 0.7,
|
||||
"name": "Artis",
|
||||
"type": "poi",
|
||||
"description": "Artis, short for Natura Artis Magistra (Latin for \"Nature is the teacher of art and science\"), is a zoo in the centre of Amsterdam. It is the oldest zoo in the Netherlands and one of the oldest zoos of mainland Europe. Artis Royal Zoo is not just a zoo, it also contains an aquarium and a planetarium. Artis also has an arboretum and a fairly large art collection. A part of the art collection is on display in the Aquarium building of the zoo. Artis contains 27 monumental buildings, most of which are used as enclosures for the animals, making Artis a unique cultural heritage of the 19th century."
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
<string name="activity_minmax_zoom">Min/Max Zoom</string>
|
||||
<string name="activity_viewpager">ViewPager</string>
|
||||
<string name="activity_runtime_style">Runtime Style</string>
|
||||
<string name="activity_data_driven_style">Data Driven Style</string>
|
||||
<string name="activity_circle_layer">Circle layer</string>
|
||||
<string name="activity_style_file">Local Style file</string>
|
||||
<string name="activity_geojson_clustering">GeoJson Clustering</string>
|
||||
@@ -100,6 +101,7 @@
|
||||
<string name="description_dynamic_info_window_adapter">Learn how to create a dynamic custom InfoWindow</string>
|
||||
<string name="description_viewpager">Use SupportMapFragments in a ViewPager</string>
|
||||
<string name="description_runtime_style">Adopt the map style on the fly</string>
|
||||
<string name="description_data_driven_style">Use functions to change the map appearance</string>
|
||||
<string name="description_symbol_layer">Manipulate symbols at runtime</string>
|
||||
<string name="description_custom_sprite">Use a custom sprite in a Symbol Layer</string>
|
||||
<string name="description_geojson_clustering">Use GeoJson sources and dynamic layers to cluster information</string>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.mapbox.mapboxsdk.style.layers.Function.stop;
|
||||
import static com.mapbox.mapboxsdk.style.layers.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
|
||||
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.interval;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.lineBlur;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -15,9 +18,10 @@ public class FunctionTest {
|
||||
|
||||
@Test
|
||||
public void testZoomFunction() {
|
||||
Function zoomF = zoom(
|
||||
Function<Float, Float> zoomF = zoom(interval(
|
||||
stop(1f, lineBlur(1f)),
|
||||
stop(10f, lineBlur(20f))
|
||||
)
|
||||
);
|
||||
|
||||
assertNotNull(zoomF.toValueObject());
|
||||
|
||||
@@ -10,7 +10,7 @@ require('../../../scripts/style-code');
|
||||
// Specification parsing //
|
||||
|
||||
// Collect layer types from spec
|
||||
const layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
var layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
const layoutProperties = Object.keys(spec[`layout_${type}`]).reduce((memo, name) => {
|
||||
if (name !== 'visibility') {
|
||||
spec[`layout_${type}`][name].name = name;
|
||||
@@ -34,6 +34,9 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {
|
||||
};
|
||||
});
|
||||
|
||||
// XXX Remove fill-extrusion layer for now
|
||||
layers = _(layers).filter(layer => layer.type != "fill-extrusion").value();
|
||||
|
||||
// Process all layer properties
|
||||
const layoutProperties = _(layers).map('layoutProperties').flatten().value();
|
||||
const paintProperties = _(layers).map('paintProperties').flatten().value();
|
||||
@@ -212,6 +215,14 @@ global.propertyValueDoc = function (property, value) {
|
||||
return doc;
|
||||
};
|
||||
|
||||
global.supportsZoomFunction = function (property) {
|
||||
return property['zoom-function'] === true;
|
||||
};
|
||||
|
||||
global.supportsPropertyFunction = function (property) {
|
||||
return property['property-function'] === true;
|
||||
};
|
||||
|
||||
// Template processing //
|
||||
|
||||
// Java + JNI Layers (Peer model)
|
||||
|
||||
@@ -4,48 +4,217 @@
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../../conversion/constant.hpp"
|
||||
#include "types.hpp"
|
||||
#include "function.hpp"
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
template <class T>
|
||||
inline jni::jobject* toFunctionStopJavaArray(jni::JNIEnv& env, std::vector<std::pair<float, T>> value) {
|
||||
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/Function$Stop")).release();
|
||||
/**
|
||||
* Conversion from core composite value to java type
|
||||
*/
|
||||
class CategoricalValueEvaluator {
|
||||
public:
|
||||
|
||||
CategoricalValueEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
template <class T>
|
||||
jni::jobject* operator()(const T &value) const {
|
||||
return *convert<jni::jobject*, T>(env, value);
|
||||
}
|
||||
|
||||
private:
|
||||
jni::JNIEnv& env;
|
||||
};
|
||||
|
||||
/**
|
||||
* Conversion from core composite value to java type
|
||||
*/
|
||||
template <>
|
||||
struct Converter<jni::jobject*, mbgl::style::CategoricalValue> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::CategoricalValue& value) const {
|
||||
CategoricalValueEvaluator evaluator(env);
|
||||
return apply_visitor(evaluator, value);
|
||||
}
|
||||
};
|
||||
|
||||
template <class I, class O>
|
||||
inline jni::jobject* toFunctionStopJavaArray(jni::JNIEnv& env, std::map<I, O> value) {
|
||||
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/Stop")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "(Ljava/lang/Object;Ljava/lang/Object;)V");
|
||||
|
||||
jni::jarray<jni::jobject>& jarray = jni::NewObjectArray(env, value.size(), *javaClass);
|
||||
|
||||
for(size_t i = 0; i < value.size(); i = i + 1) {
|
||||
jni::jobject* in = *convert<jni::jobject*, float>(env, value[i].first);
|
||||
jni::jobject* out = *convert<jni::jobject*, T>(env, value[i].second);
|
||||
size_t i = 0;
|
||||
for (auto const& stop : value) {
|
||||
jni::jobject* in = *convert<jni::jobject*, I>(env, stop.first);
|
||||
jni::jobject* out = *convert<jni::jobject*, O>(env, stop.second);
|
||||
jni::SetObjectArrayElement(env, jarray, i, &jni::NewObject(env, *javaClass, *constructor, in, out));
|
||||
i++;
|
||||
jni::DeleteLocalRef(env, in);
|
||||
jni::DeleteLocalRef(env, out);
|
||||
}
|
||||
|
||||
return &jarray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion from core function stops to Stops java subclasses
|
||||
*/
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::Function<T>> {
|
||||
class StopsEvaluator {
|
||||
public:
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::Function<T>& value) const {
|
||||
static jni::jclass* javaClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/layers/Function")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *javaClass, "<init>", "([Lcom/mapbox/mapboxsdk/style/layers/Function$Stop;)V");
|
||||
static jni::jmethodID* withBase = &jni::GetMethodID(env, *javaClass, "withBase", "(F)Lcom/mapbox/mapboxsdk/style/layers/Function;");
|
||||
StopsEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
// Create object
|
||||
jni::jobject* jfunction = &jni::NewObject(env, *javaClass, *constructor, *toFunctionStopJavaArray(env, value.getStops()));
|
||||
jni::jobject* operator()(const mbgl::style::CategoricalStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/CategoricalStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "([Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
|
||||
// Set base
|
||||
jni::CallMethod<jni::jobject*>(env, jfunction, *withBase, value.getBase());
|
||||
return &jni::NewObject(env, *clazz, *constructor, toFunctionStopJavaArray(env, value.stops));
|
||||
}
|
||||
|
||||
return {jfunction};
|
||||
jni::jobject* operator()(const mbgl::style::ExponentialStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/ExponentialStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "(Ljava/lang/Float;[Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor,
|
||||
*convert<jni::jobject*>(env, value.base),
|
||||
toFunctionStopJavaArray(env, value.stops));
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::IdentityStops<T> &) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/IdentityStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "()V");
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::IntervalStops<T> &value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/IntervalStops")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "([Lcom/mapbox/mapboxsdk/style/functions/stops/Stop;)V");
|
||||
|
||||
return &jni::NewObject(env, *clazz, *constructor, toFunctionStopJavaArray(env, value.stops));
|
||||
}
|
||||
|
||||
private:
|
||||
jni::JNIEnv& env;
|
||||
};
|
||||
|
||||
template <class T, typename X>
|
||||
inline jni::jobject* convertCompositeStopsArray(jni::JNIEnv& env, std::map<float, T> value) {
|
||||
// Create Java Map
|
||||
static jni::jclass* mapClass = jni::NewGlobalRef(env, &jni::FindClass(env, "java/util/HashMap")).release();
|
||||
static jni::jmethodID* mapConstructor = &jni::GetMethodID(env, *mapClass, "<init>", "()V");
|
||||
static jni::jmethodID* mapPutMethod = &jni::GetMethodID(env, *mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
||||
jni::jobject& map = jni::NewObject(env, *mapClass, *mapConstructor);
|
||||
|
||||
// Add converted Stops for each zoom value
|
||||
StopsEvaluator<X> evaluator(env);
|
||||
for (auto const& entry : value) {
|
||||
jni::jobject* zoom = *convert<jni::jobject*, float>(env, entry.first);
|
||||
jni::jobject* stops = evaluator(entry.second);
|
||||
jni::CallMethod<jni::jobject*>(env, &map, *mapPutMethod, zoom, stops);
|
||||
jni::DeleteLocalRef(env, zoom);
|
||||
jni::DeleteLocalRef(env, stops);
|
||||
}
|
||||
|
||||
// Create CompositeStops from Java Map
|
||||
static jni::jclass* compositeStopsClass = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/stops/CompositeStops")).release();
|
||||
static jni::jmethodID* compositeStopsConstructor = &jni::GetMethodID(env, *compositeStopsClass, "<init>", "(Ljava/util/Map;)V");
|
||||
jni::jobject& compositeStops = jni::NewObject(env, *compositeStopsClass, *compositeStopsConstructor, &map);
|
||||
jni::DeleteLocalRef(env, &map);
|
||||
|
||||
return &compositeStops;
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversion from core composite function stops to CompositeFunctionStops java type
|
||||
*/
|
||||
template <class T>
|
||||
class CompositeStopsEvaluator {
|
||||
public:
|
||||
|
||||
CompositeStopsEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::CategoricalStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::CategoricalStops<T>, T>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::ExponentialStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::ExponentialStops<T>, T>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const std::map<float, mbgl::style::IntervalStops<T>> &value) const {
|
||||
return convertCompositeStopsArray<mbgl::style::IntervalStops<T>, T>(env, value);
|
||||
}
|
||||
|
||||
private:
|
||||
jni::JNIEnv& env;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::CameraFunction<T>> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::CameraFunction<T>& value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/CameraFunction")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>", "(Lcom/mapbox/mapboxsdk/style/functions/stops/Stops;)V");
|
||||
|
||||
StopsEvaluator<T> evaluator(env);
|
||||
jni::jobject* stops = apply_visitor(evaluator, value.stops);
|
||||
jni::jobject* converted = &jni::NewObject(env, *clazz, *constructor, stops);
|
||||
|
||||
return { converted };
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::SourceFunction<T>> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::SourceFunction<T>& value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/SourceFunction")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>",
|
||||
"(Ljava/lang/Object;Ljava/lang/String;Lcom/mapbox/mapboxsdk/style/functions/stops/Stops;)V");
|
||||
|
||||
// Convert stops
|
||||
StopsEvaluator<T> evaluator(env);
|
||||
jni::jobject* stops = apply_visitor(evaluator, value.stops);
|
||||
|
||||
// Convert default value
|
||||
jni::jobject* defaultValue = nullptr;
|
||||
if (value.defaultValue) {
|
||||
defaultValue = *convert<jni::jobject*>(env, *value.defaultValue);
|
||||
}
|
||||
|
||||
return { &jni::NewObject(env, *clazz, *constructor, defaultValue, jni::Make<jni::String>(env, value.property).Get(), stops) };
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::CompositeFunction<T>> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::CompositeFunction<T>& value) const {
|
||||
static jni::jclass* clazz = jni::NewGlobalRef(env, &jni::FindClass(env, "com/mapbox/mapboxsdk/style/functions/CompositeFunction")).release();
|
||||
static jni::jmethodID* constructor = &jni::GetMethodID(env, *clazz, "<init>",
|
||||
"(Ljava/lang/Object;Ljava/lang/String;Lcom/mapbox/mapboxsdk/style/functions/stops/CompositeStops;)V");
|
||||
|
||||
// Convert stops
|
||||
CompositeStopsEvaluator<T> evaluator(env);
|
||||
jni::jobject* stops = apply_visitor(evaluator, value.stops);
|
||||
|
||||
|
||||
// Convert default value
|
||||
jni::jobject* defaultValue = nullptr;
|
||||
if (value.defaultValue) {
|
||||
defaultValue = *convert<jni::jobject*>(env, *value.defaultValue);
|
||||
}
|
||||
|
||||
return { &jni::NewObject(env, *clazz, *constructor, defaultValue, jni::Make<jni::String>(env, value.property).Get(), stops) };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/style/property_value.hpp>
|
||||
#include <mbgl/style/data_driven_property_value.hpp>
|
||||
#include "../../conversion/conversion.hpp"
|
||||
#include "../../conversion/constant.hpp"
|
||||
#include "types.hpp"
|
||||
@@ -10,26 +11,62 @@ namespace mbgl {
|
||||
namespace android {
|
||||
namespace conversion {
|
||||
|
||||
/**
|
||||
* Conversion from core property value types to Java property value types
|
||||
*/
|
||||
template <typename T>
|
||||
class PropertyValueEvaluator {
|
||||
public:
|
||||
|
||||
PropertyValueEvaluator(jni::JNIEnv& _env) : env(_env) {}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::Undefined) const {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const T &value) const {
|
||||
Result<jni::jobject*> result = convert<jni::jobject*>(env, value);
|
||||
return *result;
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::CameraFunction<T> &value) const {
|
||||
return *convert<jni::jobject*, mbgl::style::CameraFunction<T>>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::SourceFunction<T> &value) const {
|
||||
return *convert<jni::jobject*, mbgl::style::SourceFunction<T>>(env, value);
|
||||
}
|
||||
|
||||
jni::jobject* operator()(const mbgl::style::CompositeFunction<T> &value) const {
|
||||
return *convert<jni::jobject*, mbgl::style::CompositeFunction<T>>(env, value);
|
||||
}
|
||||
|
||||
private:
|
||||
jni::JNIEnv& env;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert core property values to java
|
||||
*/
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::PropertyValue<T>> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::PropertyValue<T>& value) const {
|
||||
PropertyValueEvaluator<T> evaluator(env);
|
||||
return value.evaluate(evaluator);
|
||||
}
|
||||
};
|
||||
|
||||
if(value.isUndefined()) {
|
||||
// Return a nullptr representing a Java null value
|
||||
return {nullptr};
|
||||
} else if (value.isConstant()) {
|
||||
// Time to convert the constant value
|
||||
Result<jni::jobject*> result = convert<jni::jobject*, T>(env, value.asConstant());
|
||||
return {*result};
|
||||
// return converted;
|
||||
} else if (value.isFunction()) {
|
||||
// Must be a function than
|
||||
return convert<jni::jobject*, mbgl::style::Function<T>>(env, value.asFunction());
|
||||
} else {
|
||||
throw std::runtime_error("Unknown property value type");
|
||||
}
|
||||
/**
|
||||
* Convert core data driven property values to java
|
||||
*/
|
||||
template <class T>
|
||||
struct Converter<jni::jobject*, mbgl::style::DataDrivenPropertyValue<T>> {
|
||||
|
||||
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::DataDrivenPropertyValue<T>& value) const {
|
||||
PropertyValueEvaluator<T> evaluator(env);
|
||||
return value.evaluate(evaluator);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user